Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Filter Duplicate Boosts #36

Merged
merged 13 commits into from Jan 29, 2024
Merged

Conversation

sneakers-the-rat
Copy link
Collaborator

@sneakers-the-rat sneakers-the-rat commented Jan 25, 2024

https://wiki.neuromatch.social/Filter_Duplicate_Boosts

It's annoying to see the same boost in the local TL all the time. This PR filters public feeds so only the most recent boost of a post is displayed.

It modifies the SQL query s.t. it looks like this:

SELECT "statuses"."id",
       "statuses"."updated_at"
FROM "statuses"
INNER JOIN "accounts" ON "accounts"."id" = "statuses"."account_id"
WHERE "statuses"."visibility" = $1
  AND "accounts"."suspended_at" IS NULL
  AND "accounts"."silenced_at" IS NULL
  AND (statuses.reply = FALSE
       OR statuses.in_reply_to_account_id = statuses.account_id)
  AND ("statuses"."reblog_of_id" IS NULL
       OR "statuses"."id" =
         (SELECT MAX(id)
          FROM statuses s2
          WHERE s2.reblog_of_id = statuses.reblog_of_id))
  AND ("statuses"."local" = $2
       OR "statuses"."uri" IS NULL)
  AND "statuses"."deleted_at" IS NULL
  AND 1=1
  AND "statuses"."id" < 111813463418866657
ORDER BY "statuses"."id" DESC LIMIT $3 [["visibility", 0], ["local", true], ["LIMIT", 20]]

So the feed selects statuses that are either a) not boosts (reblog_of_id IS NULL), or b) are a boost that has the maximum ID for all posts with a matching reblog_of_id column

Before merging:

  • need to also take the pagination parameters from the get call and pass them to the without_duplicate_reblogs scope, because otherwise we will be querying all boosts and statuses every time.
  • tests!

@sneakers-the-rat sneakers-the-rat marked this pull request as ready for review January 29, 2024 01:07
@sneakers-the-rat sneakers-the-rat merged commit bb3abe1 into dev Jan 29, 2024
58 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant