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

Enable DB table names customization #535

Merged
merged 1 commit into from
Mar 3, 2022
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
3 changes: 2 additions & 1 deletion engine/app/charts/good_job/scheduled_by_queue_chart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def initialize(filter)
def data
end_time = Time.current
start_time = end_time - 1.day
table_name = GoodJob::ActiveJobJob.table_name

count_query = Arel.sql(GoodJob::Execution.pg_or_jdbc_query(<<~SQL.squish))
SELECT *
Expand All @@ -23,7 +24,7 @@ def data
queue_name,
count(*) AS count
FROM (
#{@filter.filtered_query.except(:select, :order).select('queue_name', 'COALESCE(good_jobs.scheduled_at, good_jobs.created_at)::timestamp AS scheduled_at').to_sql}
#{@filter.filtered_query.except(:select, :order).select('queue_name', "COALESCE(#{table_name}.scheduled_at, #{table_name}.created_at)::timestamp AS scheduled_at").to_sql}
) sources
GROUP BY date_trunc('hour', scheduled_at), queue_name
) sources ON sources.scheduled_at = timestamp
Expand Down
4 changes: 2 additions & 2 deletions engine/app/filters/good_job/jobs_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def states

def filtered_query
query = base_query.includes(:executions)
.joins_advisory_locks.select('good_jobs.*', 'pg_locks.locktype AS locktype')
.joins_advisory_locks.select("#{GoodJob::ActiveJobJob.table_name}.*", 'pg_locks.locktype AS locktype')

query = query.job_class(params[:job_class]) if params[:job_class].present?
query = query.where(queue_name: params[:queue_name]) if params[:queue_name].present?
Expand All @@ -31,7 +31,7 @@ def filtered_query
when 'scheduled'
query = query.scheduled
when 'running'
query = query.running.select('good_jobs.*', 'pg_locks.locktype')
query = query.running.select("#{GoodJob::ActiveJobJob.table_name}.*", 'pg_locks.locktype')
when 'queued'
query = query.queued
end
Expand Down