mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
BUGFIX: Top page wasn't display any topics
This commit is contained in:
parent
6e2797112d
commit
871adc0b0f
@ -29,7 +29,6 @@ Discourse.TopController = Discourse.ObjectController.extend({
|
|||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}.property(),
|
}.property()
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Discourse.ListTopRoute = Discourse.Route.extend({
|
Discourse.ListTopRoute = Discourse.Route.extend({
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
|
this._super();
|
||||||
// will mark the "top" navigation item as selected
|
// will mark the "top" navigation item as selected
|
||||||
this.controllerFor('list').setProperties({
|
this.controllerFor('list').setProperties({
|
||||||
filterMode: 'top',
|
filterMode: 'top',
|
||||||
@ -8,8 +9,11 @@ Discourse.ListTopRoute = Discourse.Route.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
model: function() {
|
setupController: function() {
|
||||||
return Discourse.TopList.find();
|
var topController = this.controllerFor("top");
|
||||||
|
Discourse.TopList.find().then(function (result) {
|
||||||
|
topController.set("model", result);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate: function() {
|
renderTemplate: function() {
|
||||||
@ -17,6 +21,7 @@ Discourse.ListTopRoute = Discourse.Route.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
deactivate: function() {
|
deactivate: function() {
|
||||||
|
this._super();
|
||||||
// Clear any filters when we leave the route
|
// Clear any filters when we leave the route
|
||||||
Discourse.URL.set('queryParams', null);
|
Discourse.URL.set('queryParams', null);
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,10 @@ class TopTopic < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.update_posts_count_for(period)
|
def self.update_posts_count_for(period)
|
||||||
sql = "SELECT topic_id, GREATEST(COUNT(*), 1) AS count
|
sql = "SELECT topic_id, GREATEST(COUNT(*), 1) AS count
|
||||||
FROM posts p
|
FROM posts
|
||||||
WHERE p.created_at >= :from
|
WHERE created_at >= :from
|
||||||
AND p.deleted_at IS NULL
|
AND deleted_at IS NULL
|
||||||
AND NOT p.hidden
|
AND NOT hidden
|
||||||
AND post_type = #{Post.types[:regular]}
|
AND post_type = #{Post.types[:regular]}
|
||||||
AND user_id <> #{Discourse.system_user.id}
|
AND user_id <> #{Discourse.system_user.id}
|
||||||
GROUP BY topic_id"
|
GROUP BY topic_id"
|
||||||
@ -50,8 +50,8 @@ class TopTopic < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.update_views_count_for(period)
|
def self.update_views_count_for(period)
|
||||||
sql = "SELECT parent_id as topic_id, COUNT(*) AS count
|
sql = "SELECT parent_id as topic_id, COUNT(*) AS count
|
||||||
FROM views v
|
FROM views
|
||||||
WHERE v.viewed_at >= :from
|
WHERE viewed_at >= :from
|
||||||
GROUP BY topic_id"
|
GROUP BY topic_id"
|
||||||
|
|
||||||
TopTopic.update_top_topics(period, "views", sql)
|
TopTopic.update_top_topics(period, "views", sql)
|
||||||
@ -59,10 +59,10 @@ class TopTopic < ActiveRecord::Base
|
|||||||
|
|
||||||
def self.update_likes_count_for(period)
|
def self.update_likes_count_for(period)
|
||||||
sql = "SELECT topic_id, GREATEST(SUM(like_count), 1) AS count
|
sql = "SELECT topic_id, GREATEST(SUM(like_count), 1) AS count
|
||||||
FROM posts p
|
FROM posts
|
||||||
WHERE p.created_at >= :from
|
WHERE created_at >= :from
|
||||||
AND p.deleted_at IS NULL
|
AND deleted_at IS NULL
|
||||||
AND NOT p.hidden
|
AND NOT hidden
|
||||||
GROUP BY topic_id"
|
GROUP BY topic_id"
|
||||||
|
|
||||||
TopTopic.update_top_topics(period, "likes", sql)
|
TopTopic.update_top_topics(period, "likes", sql)
|
||||||
@ -71,9 +71,9 @@ class TopTopic < ActiveRecord::Base
|
|||||||
def self.compute_top_score_for(period)
|
def self.compute_top_score_for(period)
|
||||||
# log(views) + (posts * likes)
|
# log(views) + (posts * likes)
|
||||||
exec_sql("UPDATE top_topics
|
exec_sql("UPDATE top_topics
|
||||||
SET #{period}_score = CASE #{period}_views_count
|
SET #{period}_score = CASE
|
||||||
WHEN 0 THEN 0
|
WHEN #{period}_views_count = 0 THEN 0
|
||||||
ELSE log(#{period}_views_count) + (#{period}_posts_count * #{period}_likes_count)
|
ELSE log(#{period}_views_count) + (#{period}_posts_count * #{period}_likes_count)
|
||||||
END")
|
END")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user