FIX: Solutions directory item was using post creation instead of solved creation

This commit is contained in:
Nat 2025-04-09 13:55:54 +08:00
parent 6e12858bde
commit 83bf6e317b
No known key found for this signature in database
GPG Key ID: 4938B35D927EC773
2 changed files with 4 additions and 4 deletions

View File

@ -295,7 +295,7 @@ after_initialize do
FROM discourse_solved_solved_topics AS st
JOIN posts AS p
ON p.id = st.answer_post_id
AND COALESCE(p.created_at, :since) > :since
AND COALESCE(st.created_at, :since) > :since
AND p.deleted_at IS NULL
JOIN topics AS t
ON t.id = st.topic_id

View File

@ -6,10 +6,10 @@ describe DirectoryItem, type: :model do
fab!(:admin)
fab!(:topic1) { Fabricate(:topic, archetype: "regular", user:) }
fab!(:topic_post1) { Fabricate(:post, topic: topic1, user:) }
fab!(:topic_post1) { Fabricate(:post, topic: topic1, user:, created_at: 10.years.ago) }
fab!(:topic2) { Fabricate(:topic, archetype: "regular", user:) }
fab!(:topic_post2) { Fabricate(:post, topic: topic2, user:) }
fab!(:topic_post2) { Fabricate(:post, topic: topic2, user:, created_at: 10.years.ago) }
fab!(:pm) { Fabricate(:topic, archetype: "private_message", user:, category_id: nil) }
fab!(:pm_post) { Fabricate(:post, topic: pm, user:) }
@ -97,7 +97,7 @@ describe DirectoryItem, type: :model do
expect(
DirectoryItem.find_by(
user_id: user.id,
period_type: DirectoryItem.period_types[:all],
period_type: DirectoryItem.period_types[:daily],
).solutions,
).to eq(1)
end