Fix followed tags posts in stream for posts with multiple tags

When there were posts with many followed tags they were returned
multiple times, resulting in less than 15 unique posts. That resulted in
some posts to be missed in the stream.

Fixes #4503

closes #7715
This commit is contained in:
Benjamin Neff 2018-02-16 01:42:47 +01:00 committed by Dennis Schubert
parent f0aca56c8f
commit beeb073dbe
No known key found for this signature in database
GPG key ID: 5A0304BEA7966D7E
3 changed files with 10 additions and 1 deletions

View file

@ -8,6 +8,7 @@
* Prevent duplicate mention notifications when the post is received twice [#7721](https://github.com/diaspora/diaspora/pull/7721) * Prevent duplicate mention notifications when the post is received twice [#7721](https://github.com/diaspora/diaspora/pull/7721)
* Fixed a compatiblitiy issue with non-diaspora\* webfingers [#7718](https://github.com/diaspora/diaspora/pull/7718) * Fixed a compatiblitiy issue with non-diaspora\* webfingers [#7718](https://github.com/diaspora/diaspora/pull/7718)
* Don't retry federation for accounts without a valid public key [#7717](https://github.com/diaspora/diaspora/pull/7717) * Don't retry federation for accounts without a valid public key [#7717](https://github.com/diaspora/diaspora/pull/7717)
* Fix stream generation for tagged posts with many followed tags [#7715](https://github.com/diaspora/diaspora/pull/7715)
## Features ## Features
* Add basic html5 audio/video embedding support [#6418](https://github.com/diaspora/diaspora/pull/6418) * Add basic html5 audio/video embedding support [#6418](https://github.com/diaspora/diaspora/pull/6418)

View file

@ -46,7 +46,7 @@ class StatusMessage < Post
end end
def self.public_tag_stream(tag_ids) def self.public_tag_stream(tag_ids)
all_public.tag_stream(tag_ids) all_public.select("DISTINCT #{table_name}.*").tag_stream(tag_ids)
end end
def self.tag_stream(tag_ids) def self.tag_stream(tag_ids)

View file

@ -51,6 +51,14 @@ describe StatusMessage, type: :model do
it "returns public status messages tagged with the tag" do it "returns public status messages tagged with the tag" do
expect(StatusMessage.public_tag_stream([@tag_id])).to eq([@status_message_1]) expect(StatusMessage.public_tag_stream([@tag_id])).to eq([@status_message_1])
end end
it "returns a post with two tags only once" do
status_message = FactoryGirl.create(:status_message, text: "#hashtag #test", public: true)
test_tag_id = ActsAsTaggableOn::Tag.where(name: "test").first.id
expect(StatusMessage.public_tag_stream([@tag_id, test_tag_id]))
.to match_array([@status_message_1, status_message])
end
end end
describe ".user_tag_stream" do describe ".user_tag_stream" do