diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2018-02-16 03:42:47 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2018-02-25 06:35:49 +0300 |
commit | beeb073dbe0d95b0dd38c91f8b129fc0039bd3a0 (patch) | |
tree | a15e0eb14b6950bf05f6317bff8d577efef8dc0e | |
parent | f0aca56c8f0cbb8ffd1f47e712bd29cb6a982553 (diff) |
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
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | app/models/status_message.rb | 2 | ||||
-rw-r--r-- | spec/models/status_message_spec.rb | 8 |
3 files changed, 10 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index e96ed8bed..a1c9a5496 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ * 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) * 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 * Add basic html5 audio/video embedding support [#6418](https://github.com/diaspora/diaspora/pull/6418) diff --git a/app/models/status_message.rb b/app/models/status_message.rb index a44afca90..17d267797 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -46,7 +46,7 @@ class StatusMessage < Post end def self.public_tag_stream(tag_ids) - all_public.tag_stream(tag_ids) + all_public.select("DISTINCT #{table_name}.*").tag_stream(tag_ids) end def self.tag_stream(tag_ids) diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 8dfca6f67..bd9d809ce 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -51,6 +51,14 @@ describe StatusMessage, type: :model do it "returns public status messages tagged with the tag" do expect(StatusMessage.public_tag_stream([@tag_id])).to eq([@status_message_1]) 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 describe ".user_tag_stream" do |