test
This commit is contained in:
parent
a92d33300b
commit
ad46564545
|
@ -3,14 +3,16 @@ namespace :hjq do
|
|||
desc "news order"
|
||||
task :users => :environment do
|
||||
a = []
|
||||
news = News.where("course_id =?", 122)
|
||||
news.each do |new|
|
||||
# news = News.where("course_id =?", 122)
|
||||
course.news.each do |new|
|
||||
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
|
||||
a << new
|
||||
a << latest_comment
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue