Skip to content

Commit 554afd5

Browse files
committed
Removing pending_jobs column
* Without always updating it on the fly, it's always the same as total_jobs, or is 0. So it's not really useful as a distinct column
1 parent 6effa16 commit 554afd5

File tree

5 files changed

+4
-8
lines changed

5 files changed

+4
-8
lines changed

app/models/solid_queue/batch.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def check_completion!
6868
finished_attributes[:failed_jobs] = failed
6969
end
7070
finished_attributes[:completed_jobs] = total_jobs - failed
71-
finished_attributes[:pending_jobs] = 0
7271

7372
update!(finished_attributes)
7473
execute_callbacks

app/models/solid_queue/batch/trackable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def failed_jobs
5757
end
5858

5959
def pending_jobs
60-
finished? ? self[:pending_jobs] : batch_executions.count
60+
finished? ? 0 : batch_executions.count
6161
end
6262

6363
def progress_percentage

app/models/solid_queue/batch_execution.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_all_from_jobs(jobs)
2525

2626
total = jobs.size
2727
SolidQueue::Batch.upsert(
28-
{ batch_id:, total_jobs: total, pending_jobs: total },
28+
{ batch_id:, total_jobs: total },
2929
**provider_upsert_options
3030
)
3131
end
@@ -39,14 +39,13 @@ def provider_upsert_options
3939
{
4040
unique_by: :batch_id,
4141
on_duplicate: Arel.sql(
42-
"total_jobs = solid_queue_batches.total_jobs + excluded.total_jobs, " \
43-
"pending_jobs = solid_queue_batches.pending_jobs + excluded.pending_jobs"
42+
"total_jobs = solid_queue_batches.total_jobs + excluded.total_jobs"
4443
)
4544
}
4645
else
4746
{
4847
on_duplicate: Arel.sql(
49-
"total_jobs = total_jobs + VALUES(total_jobs), pending_jobs = pending_jobs + VALUES(pending_jobs)"
48+
"total_jobs = total_jobs + VALUES(total_jobs)"
5049
)
5150
}
5251
end

lib/generators/solid_queue/install/templates/db/queue_schema.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
t.text "on_failure"
130130
t.text "metadata"
131131
t.integer "total_jobs", default: 0, null: false
132-
t.integer "pending_jobs", default: 0, null: false
133132
t.integer "completed_jobs", default: 0, null: false
134133
t.integer "failed_jobs", default: 0, null: false
135134
t.datetime "enqueued_at"

test/dummy/db/queue_schema.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@
141141
t.text "on_failure"
142142
t.text "metadata"
143143
t.integer "total_jobs", default: 0, null: false
144-
t.integer "pending_jobs", default: 0, null: false
145144
t.integer "completed_jobs", default: 0, null: false
146145
t.integer "failed_jobs", default: 0, null: false
147146
t.datetime "enqueued_at"

0 commit comments

Comments
 (0)