FIX: remove memoized values in jobs

This commit is contained in:
Neil Lalonde 2017-05-22 16:26:18 -04:00
parent b23fc2bf84
commit 9edc490d3f
5 changed files with 11 additions and 9 deletions

View File

@ -26,7 +26,7 @@ module Jobs
end
def badge
@badge ||= Badge.find(Badge::FirstEmoji)
Badge.find(Badge::FirstEmoji)
end
end

View File

@ -25,7 +25,7 @@ module Jobs
end
def badge
@badge ||= Badge.find(Badge::FirstReplyByEmail)
Badge.find(Badge::FirstReplyByEmail)
end
end

View File

@ -35,7 +35,7 @@ module Jobs
end
def badge
@badge ||= Badge.find(Badge::FirstOnebox)
Badge.find(Badge::FirstOnebox)
end
end

View File

@ -6,17 +6,19 @@ module Jobs
def execute(args)
return true unless SiteSetting.notify_about_queued_posts_after > 0 && SiteSetting.contact_email
if should_notify_ids.size > 0 && last_notified_id.to_i < should_notify_ids.max
message = PendingQueuedPostsMailer.notify(count: should_notify_ids.size)
queued_post_ids = should_notify_ids
if queued_post_ids.size > 0 && last_notified_id.to_i < queued_post_ids.max
message = PendingQueuedPostsMailer.notify(count: queued_post_ids.size)
Email::Sender.new(message, :pending_queued_posts_reminder).send
self.last_notified_id = should_notify_ids.max
self.last_notified_id = queued_post_ids.max
end
true
end
def should_notify_ids
@_should_notify_ids ||= QueuedPost.new_posts.visible.where('created_at < ?', SiteSetting.notify_about_queued_posts_after.hours.ago).pluck(:id)
QueuedPost.new_posts.visible.where('created_at < ?', SiteSetting.notify_about_queued_posts_after.hours.ago).pluck(:id)
end
def last_notified_id
@ -28,7 +30,7 @@ module Jobs
end
def self.last_notified_key
"last_notified_queued_post_id"
"last_notified_queued_post_id".freeze
end
end
end

View File

@ -19,7 +19,7 @@ module Jobs
end
def feed_key
@feed_key ||= "feed-modified:#{Digest::SHA1.hexdigest(SiteSetting.feed_polling_url)}"
"feed-modified:#{Digest::SHA1.hexdigest(SiteSetting.feed_polling_url)}"
end
def poll_feed