实训回复特别慢

dev_aliyun
daiao 5 years ago
parent 84f77edead
commit 1287cf6d53

@ -30,14 +30,15 @@ class DiscussesService
memo_count = memos.count memo_count = memos.count
memos = memos.offset(offset).limit(15) memos = memos.offset(offset).limit(15)
#实训标签使用最多的9个 #实训标签使用最多的9个
hot_tags = TagRepertoire.find_by_sql("select a.name, sum(a.cnt) cnt, a.id from # hot_tags = TagRepertoire.find_by_sql("select a.name, sum(a.cnt) cnt, a.id from
(select tr.id, tr.name, count(d.dis_id) cnt, d.root_id, s.status, s.hidden # (select tr.id, tr.name, count(d.dis_id) cnt, d.root_id, s.status, s.hidden
from tag_repertoires tr join (shixun_tag_repertoires str # from tag_repertoires tr join (shixun_tag_repertoires str
left join (shixuns s join discusses d on d.dis_id = s.id and d.root_id is null and s.status =2 and s.hidden=false) # left join (shixuns s join discusses d on d.dis_id = s.id and d.root_id is null and s.status =2 and s.hidden=false)
on s.id = str.shixun_id) on tr.id = str.tag_repertoire_id # on s.id = str.shixun_id) on tr.id = str.tag_repertoire_id
group by d.dis_id order by cnt desc) a group by a.name # group by d.dis_id order by cnt desc) a group by a.name
order by cnt desc limit 9").map{|ht| ht.attributes.dup} # order by cnt desc limit 9").map{|ht| ht.attributes.dup}
tag_id = ShixunTagRepertoire.joins(:shixun).order("myshixuns_count desc").pluck(:tag_repertoire_id).uniq.first(9)
hot_tags = TagRepertoire.select([:id, :name]).where(:id => tag_id).order("FIELD(id, #{tag_id.join(",")})") if tag_id
memos = memo_list memos memos = memo_list memos
user_info = format_for_current_user current_user user_info = format_for_current_user current_user
hot_memos = Memo.field_for_recommend.posts.hot.limit(4) hot_memos = Memo.field_for_recommend.posts.hot.limit(4)

Loading…
Cancel
Save