correct topic and category counting query

revive old styling that was stripped
This commit is contained in:
Sam 2013-10-21 10:20:16 +11:00
parent 25723de9c8
commit 614f45d003
2 changed files with 36 additions and 9 deletions

View File

@ -197,15 +197,42 @@
}
}
#topic-list tbody tr.has-excerpt .star
{
#topic-list tbody tr.has-excerpt .star {
vertical-align: top;
margin-top: 3px;
}
#topic-list.categories {
th.latest, td.latest {
padding-left: 12px;
}
th.num {
width: 45px;
}
.last-user-info {
font-size: 12px;
margin-top: 3px;
}
tbody td {
padding-bottom: 20px;
}
.category{
position: relative;
width: 55%;
.featured-users {
position: absolute;
right: 18px;
top: 3px;
}
.category-description {
margin-top: 10px;
}
.badge-category {
padding: 6px 10px;
font-size: 14px;
}
}
}

View File

@ -114,8 +114,9 @@ class Category < ActiveRecord::Base
.visible
topics_with_post_count = Topic
.select("topics.category_id, topics.id topic_id, COUNT(*) topic_count, SUM(topics.posts_count) post_count")
.group("topics.category_id, topics.id")
.select("topics.category_id, COUNT(*) topic_count, SUM(topics.posts_count) post_count")
.where("topics.id NOT IN (select cc.topic_id from categories cc)")
.group("topics.category_id")
.visible.to_sql
topics_year = topics.created_since(1.year.ago).to_sql
@ -129,8 +130,7 @@ class Category < ActiveRecord::Base
post_count = x.post_count
FROM (#{topics_with_post_count}) x
WHERE x.category_id = c.id AND
(c.topic_count <> x.topic_count OR c.post_count <> x.post_count) AND
x.topic_id <> c.topic_id
(c.topic_count <> x.topic_count OR c.post_count <> x.post_count)
SQL