purge old friend requests
a background worker to periodically remove friend requests that have not been accepted and are more than a week ago
This commit is contained in:
parent
af1140fa05
commit
9eb8c97706
|
|
@ -83,6 +83,10 @@ module JamRuby
|
|||
return friend_request
|
||||
end
|
||||
|
||||
def self.purgeable_requests
|
||||
FriendRequest.where("status IS NULL AND created_at < ?", 1.week.ago)
|
||||
end
|
||||
|
||||
private
|
||||
def self.validate_friend_request(friend_request, user_id, friend_id)
|
||||
friend_requests = FriendRequest.where("user_id='#{user_id}' AND friend_id='#{friend_id}'")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
module JamRuby
|
||||
class FriendRequestCleaner
|
||||
extend Resque::Plugins::JamLonelyJob
|
||||
|
||||
@queue = :friend_request_cleaner
|
||||
@@log = Logging.logger[FriendRequestCleaner]
|
||||
|
||||
def self.perform
|
||||
@@log.debug("waking up")
|
||||
|
||||
FriendRequest.purgeable_requests do |request|
|
||||
request.destroy
|
||||
end
|
||||
@@log.debug("done")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -104,3 +104,8 @@ TallyAffiliates:
|
|||
cron: "0 0,4,8,12,16,20 * * *"
|
||||
class: "JamRuby::TallyAffiliates"
|
||||
description: "Tallies up affiliate totals"
|
||||
|
||||
FriendRequestCleaner:
|
||||
cron: "0 3 * * *"
|
||||
class: "JamRuby::FriendRequestCleaner"
|
||||
description: "Purge old friend requests that have not been accepted"
|
||||
|
|
|
|||
Loading…
Reference in New Issue