Skip to content
Draft
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
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ GEM
nio4r (2.7.4)
nokogiri (1.18.8-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.8-x86_64-linux-gnu)
racc (~> 1.4)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -238,6 +240,7 @@ GEM
ruby-progressbar (1.13.0)
securerandom (0.4.1)
sqlite3 (2.7.2-arm64-darwin)
sqlite3 (2.7.2-x86_64-linux-gnu)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.7)
Expand All @@ -261,6 +264,7 @@ GEM

PLATFORMS
arm64-darwin
x86_64-linux

DEPENDENCIES
bootsnap
Expand Down
32 changes: 17 additions & 15 deletions app/jobs/data_drip/dripper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module DataDrip
class Dripper < ActiveJob::Base
queue_as :data_drip
queue_as :within_24_hours
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sizief do we need to port anything else from the base job in the monorepo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this value configurable at lib/datadrip.rb? Outside factorial this queue name doesn't make a lot of sense


def perform(backfill_run)
backfill_run.running!
Expand All @@ -13,27 +13,29 @@ def perform(backfill_run)
)
scope = new_backfill.scope

scope =
scope.limit(
backfill_run.amount_of_elements
) if backfill_run.amount_of_elements.present? &&
backfill_run.amount_of_elements > 0
if backfill_run.amount_of_elements.present? &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess some formatting rules?

backfill_run.amount_of_elements > 0
scope =
scope.limit(
backfill_run.amount_of_elements
)
end

batch_ids =
scope
.find_in_batches(batch_size: backfill_run.batch_size)
.map do |batch|
{
finish_id: batch.last.id,
start_id: batch.first.id,
actual_size: batch.size
}
end
.find_in_batches(batch_size: backfill_run.batch_size)
.map do |batch|
{
finish_id: batch.last.id,
start_id: batch.first.id,
actual_size: batch.size
}
end

backfill_run.update(total_count: scope.count)

if backfill_run.amount_of_elements.present? &&
backfill_run.amount_of_elements < backfill_run.batch_size
backfill_run.amount_of_elements < backfill_run.batch_size
backfill_run.batch_size = backfill_run.amount_of_elements
backfill_run.save
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/data_drip/dripper_child.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module DataDrip
class DripperChild < ActiveJob::Base
queue_as :data_drip_child
queue_as :within_24_hours

def perform(backfill_run_batch)
parent = backfill_run_batch.backfill_run
Expand Down
Loading