-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-6901 Use ActiveJob for asynchronous indexing (#5055)
* AO3-6901 Use ActiveJob for asynchronous indexing * Update tests for AsyncIndexer * Avoid leaking queue_adapter changes to subsequent tests * Run enqueued jobs for request specs (works n+1 specs) * Fix typo in comment
- Loading branch information
1 parent
ec6c90f
commit ddc7157
Showing
7 changed files
with
75 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A job to index the record IDs queued up by AsyncIndexer. | ||
class AsyncIndexerJob < ApplicationJob | ||
REDIS = AsyncIndexer::REDIS | ||
|
||
def perform(name) | ||
indexer = name.split(":").first.constantize | ||
ids = REDIS.smembers(name) | ||
|
||
return if ids.empty? | ||
|
||
batch = indexer.new(ids).index_documents | ||
IndexSweeper.new(batch, indexer).process_batch | ||
REDIS.del(name) | ||
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