Commit 4aefab34 by Kevin Chugh

add rake task to get flagged posts

parent 5826df36
require 'rest_client'
roots = {}
roots['development'] = "http://localhost:8000"
roots['test'] = "http://localhost:8000"
roots['production'] = "http://edx.org"
ROOT = roots[ENV['SINATRA_ENV']]
namespace :flags do
task :flagged => :environment do
flagged = Content.flagged
flagged.each do |f|
if f.attributes.include? "comment_thread_id"
id = f.comment_thread_id
else
id = f.id
end
puts "#{ROOT}/courses/#{f.course_id}/discussion/forum/#{f.commentable_id}/threads/#{id}"
end
end
end
......@@ -65,6 +65,15 @@ class Comment < Content
end
end
def commentable_id
#we need this to have a universal access point for the flag rake task
if self.comment_thread_id
t = CommentThread.find self.comment_thread_id
if t
t.commentable_id
end
end
end
private
def set_thread_last_activity_at
......
......@@ -209,6 +209,11 @@ class CommentThread < Content
!!(tag =~ RE_TAG)
end
def comment_thread_id
#so that we can use the comment thread id as a common attribute for flagging
self.id
end
private
RE_HEADCHAR = /[a-z0-9]/
......@@ -237,4 +242,5 @@ private
def destroy_subscriptions
subscriptions.delete_all
end
end
......@@ -13,4 +13,15 @@ class Content
end
end
def self.flagged
#return an array of flagged content
holder = []
Content.where(:abuse_flaggers.ne => [],:abuse_flaggers.exists => true).each do |c|
holder << c
end
holder
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment