mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
BUGFIX: mitigate unbound table growth on top_topics
This commit is contained in:
parent
b046fab1c4
commit
b7ff4173c9
1 changed files with 10 additions and 2 deletions
|
@ -102,7 +102,14 @@ class TopTopic < ActiveRecord::Base
|
|||
SET #{period}_score = CASE
|
||||
WHEN #{period}_views_count = 0 THEN 0
|
||||
ELSE log(#{period}_views_count) + (#{period}_posts_count * #{period}_likes_count)
|
||||
END")
|
||||
END
|
||||
WHERE
|
||||
#{period}_score <> CASE
|
||||
WHEN #{period}_views_count = 0 THEN 0
|
||||
ELSE log(#{period}_views_count) + (#{period}_posts_count * #{period}_likes_count)
|
||||
END
|
||||
|
||||
")
|
||||
end
|
||||
|
||||
def self.start_of(period)
|
||||
|
@ -119,7 +126,8 @@ class TopTopic < ActiveRecord::Base
|
|||
SET #{period}_#{sort}_count = c.count
|
||||
FROM top_topics tt
|
||||
INNER JOIN (#{inner_join}) c ON tt.topic_id = c.topic_id
|
||||
WHERE tt.topic_id = top_topics.topic_id",
|
||||
WHERE tt.topic_id = top_topics.topic_id
|
||||
AND tt.#{period}_#{sort}_count <> c.count",
|
||||
from: start_of(period))
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue