-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore sim sets in workflow subjects count (#3144)
* add sms counter cache to workflow * add real subjects to the workflow counter * add workflow subjects count worker * call the subjects count worker when refreshing workflow data * count the subjects before running the retired count worker ensure we have an up to date count for the subjects if we need to compare the retired at counts * use AR relation methods to get the workflow_ids * count the workflow's subjects after counting a sets ensure we recount the workflow subjects after counting a linked set's subjects. * clarify comment text * use the cached count value * inline the shared helper to point of use * avoid AR counter cache method names clashing with a counter cache means this method proxies up to AR .empty? checks * use real_set_member_subjects_count column name * count and cache the number of real subjects for the workflow * use the workflow counter cache for subjects_count * remove unused live_subejcts_sets association * build the associations correctly and cache the real subjects count * use the real_set_member_subjects_count attribute * correct the memoized instance variable name * add workflow subjects_count migration task ensure we backfill the workflow subjects_count cache values before deploying.
- Loading branch information
Showing
21 changed files
with
181 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class WorkflowSubjectsCountWorker | ||
include Sidekiq::Worker | ||
|
||
sidekiq_options queue: :data_low | ||
|
||
sidekiq_options congestion: { | ||
interval: 60, | ||
max_in_interval: 1, | ||
min_delay: 60, | ||
reject_with: :reschedule, | ||
key: ->(workflow_id) { | ||
"workflow_#{workflow_id}_subjects_count_worker" | ||
} | ||
} | ||
|
||
sidekiq_options lock: :until_executing | ||
|
||
def perform(workflow_id) | ||
workflow = Workflow.find_without_json_attrs(workflow_id) | ||
counter = WorkflowCounter.new(workflow) | ||
workflow.update_column(:real_set_member_subjects_count, counter.subjects) | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20190624094308_add_subjects_counter_cache_to_workflow.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddSubjectsCounterCacheToWorkflow < ActiveRecord::Migration | ||
def change | ||
add_column :workflows, :real_set_member_subjects_count, :integer, default: 0, null: false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.