A platform for community discussion. Free, open, simple.
FIX: Show correct dates in topic timelines (#13670)
Bianca Nenciuf74640ac58c0
diff --git a/lib/topic_view.rb b/lib/topic_view.rbindex 675b543b2d0..e97ea551453 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -608,7 +608,7 @@ class TopicViewcolumns = [:id]if !is_mega_topic?- columns << 'EXTRACT(DAYS FROM CURRENT_TIMESTAMP - posts.created_at)::INT AS days_ago'+ columns << '(EXTRACT(EPOCH FROM CURRENT_TIMESTAMP - posts.created_at) / 86400)::INT AS days_ago'endposts.pluck(*columns)diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rbindex ceef467d067..ac4e91d746a 100644--- a/spec/components/topic_view_spec.rb+++ b/spec/components/topic_view_spec.rb@@ -796,13 +796,13 @@ describe TopicView doenddescribe '#filtered_post_stream' do- let!(:post) { Fabricate(:post, topic: topic, user: first_poster) }- let!(:post2) { Fabricate(:post, topic: topic, user: evil_trout) }+ let!(:post) { Fabricate(:post, topic: topic, user: first_poster, created_at: 18.hours.ago) }+ let!(:post2) { Fabricate(:post, topic: topic, user: evil_trout, created_at: 6.hours.ago) }let!(:post3) { Fabricate(:post, topic: topic, user: first_poster) }it 'should return the right columns' doexpect(topic_view.filtered_post_stream).to eq([- [post.id, 0],+ [post.id, 1],[post2.id, 0],[post3.id, 0]])