- Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathspam.rake
43 lines (37 loc) · 1.4 KB
/
spam.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
namespace:spamdo
task:sweep=>:environmentdo
since=30.days.ago
protips=Protip.where('created_at > ?',since).where(bad_content: false);nil
good_protips=[]
protips.eachdo |p|
flags=Spaminator.new.protip_flags(p)
ifflags.any? && p.hearts_count <= 1
Rails.logger.debug"#{p.id} – #{p.title} – #{p.body[0..100].gsub("\n",'')}"
Rails.logger.debug"#{flags.inspect}"ifflags.any?
Rails.logger.debug
p.bad_content=true
p.user.bad_user=true
p.save
else
good_protips << "https://coderwall.com/p/#{p.public_id} – #{p.title}"
end
end;nil
good_users=[]
users=User.where('created_at > ?',since).where(bad_user: false);nil
users.eachdo |u|
flags=Spaminator.new.user_flags(u)
ifflags.any?
Rails.logger.debug"#{u.id} – #{u.username} – #{(u.about || '')[0..100].gsub("\n",'')}"
Rails.logger.debug"#{flags.inspect}"ifflags.any?
Rails.logger.debug
u.bad_user!
else
good_users << "https://coderwall.com/#{u.username}"
end
end;nil
["Good Users",good_users,"Good Protips",good_protips].flatten.eachdo |e|
Rails.logger.debuge
end
Rails.logger.info("spam-sweep bad-users=#{users.size - good_users.size}/#{users.size} bad-protips=#{protips.size - good_protips.size}/#{protips.size}")
end
end