Skip to content

Commit 539938b

Browse files
authored
FIX: Solutions directory item was using post creation instead of solved creation (#361)
Earlier on in the migration, the update of the user directory query was erroneously switched to use post creation date instead of the date the post was solved. This commit fixes that.
1 parent 6e12858 commit 539938b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

plugin.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def self.skip_db?
295295
FROM discourse_solved_solved_topics AS st
296296
JOIN posts AS p
297297
ON p.id = st.answer_post_id
298-
AND COALESCE(p.created_at, :since) > :since
298+
AND COALESCE(st.created_at, :since) > :since
299299
AND p.deleted_at IS NULL
300300
JOIN topics AS t
301301
ON t.id = st.topic_id

spec/models/directory_item_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
fab!(:admin)
77

88
fab!(:topic1) { Fabricate(:topic, archetype: "regular", user:) }
9-
fab!(:topic_post1) { Fabricate(:post, topic: topic1, user:) }
9+
fab!(:topic_post1) { Fabricate(:post, topic: topic1, user:, created_at: 10.years.ago) }
1010

1111
fab!(:topic2) { Fabricate(:topic, archetype: "regular", user:) }
12-
fab!(:topic_post2) { Fabricate(:post, topic: topic2, user:) }
12+
fab!(:topic_post2) { Fabricate(:post, topic: topic2, user:, created_at: 10.years.ago) }
1313

1414
fab!(:pm) { Fabricate(:topic, archetype: "private_message", user:, category_id: nil) }
1515
fab!(:pm_post) { Fabricate(:post, topic: pm, user:) }
@@ -97,7 +97,7 @@
9797
expect(
9898
DirectoryItem.find_by(
9999
user_id: user.id,
100-
period_type: DirectoryItem.period_types[:all],
100+
period_type: DirectoryItem.period_types[:daily],
101101
).solutions,
102102
).to eq(1)
103103
end

0 commit comments

Comments
 (0)