lib/decidim/cdtb/spam/user_spam_detector.rb in decidim-cdtb-0.1.4 vs lib/decidim/cdtb/spam/user_spam_detector.rb in decidim-cdtb-0.1.6
- old
+ new
@@ -33,30 +33,33 @@
def total_items
@num_users
end
+ # rubocop:disable Metrics/AbcSize
def do_execution(context)
progress_bar = context[:progress_bar]
-
CSV.open("spam_users.csv", "w") do |csv|
- csv_headers = ["ID", "Is suspicious?", "Name", "Email", "Nickname", "Personal URL", "About"]
+ csv_headers = ["ID", "Is suspicious?", "Name", "Email", "Nickname", "Personal URL", "About",
+ "Organization ID", "Organization Name"]
csv << csv_headers
@users.find_each do |user|
suspicious = "NO"
if spam_user?(user)
suspicious = "YES"
@num_applied+= 1
end
- csv << [user.id, suspicious, user.name, user.email, user.nickname, user.personal_url, user.about]
+ csv << [user.id, suspicious, user.name, user.email, user.nickname, user.personal_url, user.about,
+ user.organization.id, user.organization.name]
progress_bar.increment
end
end
end
+ # rubocop:enable Metrics/AbcSize
def end_execution(_ctx)
if @num_applied.positive?
log_task_step("#{@num_applied} suspicious users")
log_task_step("Suspicious users list exported to spam_users.csv")