Skip to content

Commit ee33626

Browse files
Remove usage of COALESCE from dashboard chart (#1306)
* Fix COALESCE timestamp generation * Remove coalesce altogether * Fix linting violation --------- Co-authored-by: Ben Sheldon [he/him] <[email protected]>
1 parent 54103a5 commit ee33626

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

app/charts/good_job/performance_index_chart.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class PerformanceIndexChart < BaseChart
55
def data
66
table_name = GoodJob::Execution.table_name
77

8-
sum_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
8+
sum_query = <<~SQL.squish
99
SELECT *
1010
FROM generate_series(
1111
date_trunc('hour', $1::timestamp),

app/charts/good_job/performance_show_chart.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def data
2121
table_name = GoodJob::Execution.table_name
2222

2323
interval_entries = BUCKET_INTERVALS.map { "interval '#{_1}'" }.join(",")
24-
sum_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
24+
sum_query = <<~SQL.squish
2525
SELECT
2626
WIDTH_BUCKET(duration, ARRAY[#{interval_entries}]) as bucket_index,
2727
COUNT(WIDTH_BUCKET(duration, ARRAY[#{interval_entries}])) AS count

app/charts/good_job/scheduled_by_queue_chart.rb

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ def initialize(filter)
88
end
99

1010
def data
11-
table_name = GoodJob::Job.table_name
12-
13-
count_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
11+
count_query = <<~SQL.squish
1412
SELECT *
1513
FROM generate_series(
1614
date_trunc('hour', $1::timestamp),
@@ -23,7 +21,7 @@ def data
2321
queue_name,
2422
count(*) AS count
2523
FROM (
26-
#{@filter.filtered_query.except(:select, :order).select('queue_name', "COALESCE(#{table_name}.scheduled_at, #{table_name}.created_at)::timestamp AS scheduled_at").to_sql}
24+
#{@filter.filtered_query.except(:select, :order).select(:queue_name, :scheduled_at).to_sql}
2725
) sources
2826
GROUP BY date_trunc('hour', scheduled_at), queue_name
2927
) sources ON sources.scheduled_at = timestamp

0 commit comments

Comments
 (0)