test
This commit is contained in:
parent
a92d33300b
commit
ad46564545
|
@ -3,14 +3,16 @@ namespace :hjq do
|
||||||
desc "news order"
|
desc "news order"
|
||||||
task :users => :environment do
|
task :users => :environment do
|
||||||
a = []
|
a = []
|
||||||
news = News.where("course_id =?", 122)
|
# news = News.where("course_id =?", 122)
|
||||||
news.each do |new|
|
course.news.each do |new|
|
||||||
unless new.comments.blank?
|
unless new.comments.blank?
|
||||||
new = new.comments.sort! { |a,b| a.created_on <=> b.created_on}.last.commented
|
latest_comment = new.comments.sort! { |a,b| a.created_on <=> b.created_on}.last
|
||||||
end
|
end
|
||||||
a << new
|
a << latest_comment
|
||||||
end
|
end
|
||||||
puts a.length
|
comments = a.map(&:commented_id).detect{|a.b| a.created_on <=> b.created_on}
|
||||||
|
# comments = a.sort!{|a.b| a.created_on <=> b.created_on}
|
||||||
|
news = News.where("id in (?)", comments)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue