Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of COALESCE from dashboard chart #1306

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/charts/good_job/performance_index_chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class PerformanceIndexChart < BaseChart
def data
table_name = GoodJob::Execution.table_name

sum_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
sum_query = <<~SQL.squish
SELECT *
FROM generate_series(
date_trunc('hour', $1::timestamp),
Expand Down
2 changes: 1 addition & 1 deletion app/charts/good_job/performance_show_chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def data
table_name = GoodJob::Execution.table_name

interval_entries = BUCKET_INTERVALS.map { "interval '#{_1}'" }.join(",")
sum_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
sum_query = <<~SQL.squish
SELECT
WIDTH_BUCKET(duration, ARRAY[#{interval_entries}]) as bucket_index,
COUNT(WIDTH_BUCKET(duration, ARRAY[#{interval_entries}])) AS count
Expand Down
6 changes: 2 additions & 4 deletions app/charts/good_job/scheduled_by_queue_chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ def initialize(filter)
end

def data
table_name = GoodJob::Job.table_name

count_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
count_query = <<~SQL.squish
SELECT *
FROM generate_series(
date_trunc('hour', $1::timestamp),
Expand All @@ -23,7 +21,7 @@ def data
queue_name,
count(*) AS count
FROM (
#{@filter.filtered_query.except(:select, :order).select('queue_name', "COALESCE(#{table_name}.scheduled_at, #{table_name}.created_at)::timestamp AS scheduled_at").to_sql}
#{@filter.filtered_query.except(:select, :order).select(:queue_name, :scheduled_at).to_sql}
) sources
GROUP BY date_trunc('hour', scheduled_at), queue_name
) sources ON sources.scheduled_at = timestamp
Expand Down