add async processing for top tagger
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,3 +24,4 @@ danbooru.sublime-project
|
|||||||
danbooru.sublime-workspace
|
danbooru.sublime-workspace
|
||||||
script/scratch.*
|
script/scratch.*
|
||||||
test/fixtures/vcr_cassettes
|
test/fixtures/vcr_cassettes
|
||||||
|
.gitconfig
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ class PostKeeperManager
|
|||||||
# archive db being up; we don't want to block updates in case it goes down.
|
# archive db being up; we don't want to block updates in case it goes down.
|
||||||
# so we need to permit async updates also.
|
# so we need to permit async updates also.
|
||||||
|
|
||||||
def self.queue_check(post_id, updater_id, increment_tags)
|
def self.queue_check(post_id, updater_id)
|
||||||
delay(queue: "default").check_and_update(post_id, updater_id, increment_tags, false)
|
delay(queue: "default", run_at: 1.minute.from_now).check_and_update(post_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_and_update(post, updater_id = nil, increment_tags = nil)
|
def self.check_and_update(post, updater_id = nil, increment_tags = nil)
|
||||||
|
|||||||
@@ -552,6 +552,9 @@ class Post < ApplicationRecord
|
|||||||
if PostKeeperManager.enabled? && persisted?
|
if PostKeeperManager.enabled? && persisted?
|
||||||
# no need to do this check on the initial create
|
# no need to do this check on the initial create
|
||||||
PostKeeperManager.check_and_update(self, CurrentUser.id, increment_tags)
|
PostKeeperManager.check_and_update(self, CurrentUser.id, increment_tags)
|
||||||
|
|
||||||
|
# run this again async to check for race conditions
|
||||||
|
PostKeeperManager.queue_check(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user