Fix duplicate activity stream posts
This commit is contained in:
parent
f91734028c
commit
ba26175421
2 changed files with 11 additions and 1 deletions
|
|
@ -24,6 +24,7 @@ module EvilQuery
|
||||||
"participations.target_type = 'Post'")
|
"participations.target_type = 'Post'")
|
||||||
.where(::Participation.arel_table[:author_id].eq(author_id).or(Post.arel_table[:author_id].eq(author_id)))
|
.where(::Participation.arel_table[:author_id].eq(author_id).or(Post.arel_table[:author_id].eq(author_id)))
|
||||||
.order("posts.interacted_at DESC")
|
.order("posts.interacted_at DESC")
|
||||||
|
.distinct
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ describe EvilQuery::Participation do
|
||||||
|
|
||||||
describe "multiple participations" do
|
describe "multiple participations" do
|
||||||
before do
|
before do
|
||||||
@status_message = FactoryGirl.create(:status_message, author: bob.person)
|
|
||||||
@like = alice.like!(@status_message)
|
@like = alice.like!(@status_message)
|
||||||
@comment = alice.comment!(@status_message, "party")
|
@comment = alice.comment!(@status_message, "party")
|
||||||
end
|
end
|
||||||
|
|
@ -101,6 +100,16 @@ describe EvilQuery::Participation do
|
||||||
expect(posts.map(&:id)).to eq([@status_message.id])
|
expect(posts.map(&:id)).to eq([@status_message.id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "includes Posts with multiple participations only once" do
|
||||||
|
eve.like!(@status_message)
|
||||||
|
expect(posts.count).to be(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "includes Posts with multiple participations only once for the post author" do
|
||||||
|
eve.like!(@status_message)
|
||||||
|
expect(EvilQuery::Participation.new(bob).posts.count).to eq(1)
|
||||||
|
end
|
||||||
|
|
||||||
it "includes Posts with multiple participation after removing one participation" do
|
it "includes Posts with multiple participation after removing one participation" do
|
||||||
@like.destroy
|
@like.destroy
|
||||||
expect(posts.map(&:id)).to eq([@status_message.id])
|
expect(posts.map(&:id)).to eq([@status_message.id])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue