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

Move read_only posts to its own endpoint, to correctly sort by PostActions #5505

Open
5 tasks done
dessalines opened this issue Mar 13, 2025 · 5 comments
Open
5 tasks done
Labels
enhancement New feature or request
Milestone

Comments

@dessalines
Copy link
Member

dessalines commented Mar 13, 2025

Requirements

  • Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support or the matrix chat.
  • Did you check to see if this issue already exists?
  • Is this only a feature request? Do not put multiple feature requests in one issue.
  • Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
  • Do you agree to follow the rules in our Code of Conduct?

Is your proposal related to a problem?

As I'm working on cursor pagination in #5429, I'm realizing that its not a good idea to try to include read only posts into list_posts, because it uses a sort key from a different table. It uses post_actions_keys::read to sort, whereas every other one uses the Post table keys.

Similar to liked_only, it should be extracted to its own endpoint, with a predictable order, and none of the filters.

Describe the solution you'd like.

Create a post/read/list endpoint, which uses a proper post_actions::read sort.

Describe alternatives you've considered.

NA

Additional context

#4499
#5429

@dessalines dessalines added the enhancement New feature or request label Mar 13, 2025
@dessalines dessalines added this to the 1.0.0 milestone Mar 13, 2025
@dullbananas
Copy link
Collaborator

The type of action to list posts for (read, like, etc) should be a query parameter

@Nutomic
Copy link
Member

Nutomic commented Mar 14, 2025

Why does it matter which table the sort key is from? Anyway the parameters get passed into PostQuery, so it should work fine with the same endpoint.

@dessalines
Copy link
Member Author

dessalines commented Mar 14, 2025

I'm in the process of cleaning up post_view.rs which is a complete mess right now, and because we've tried to make it too versatile, we have a lot of overly complicated cases where the sorting column(s) change based on these params. I'm restricting and cleaning this up so that it can only do front page sorts / feeds. To get into the details, building a cursor for post_actions requires putting a lot of extra info in the cursor, which isn't necessary if I only restrict this cursor to a Post, which contains all the necessary sorting keys.

PostQuery / list_posts should now only be used for pulling front page or community feeds.

I've removed / moved a bunch of its functionality to other endpoints anyway, so this is just part of that cleanup.

  • saved_only is removed, and is now at account/auth/saved
  • listing content by person got moved to person/content
  • I'm going to remove search_term, because post searching is now moved to search
  • I'm going to remove liked_only to its own combined endpoint, which includes liked comments
  • I'm going to move read_only to its own endpoint also, which only sorts by post_actions::read

@dessalines
Copy link
Member Author

dessalines commented Mar 14, 2025

I'd also like to note that this only has to do with ordering the posts by read.

PostQuery already has a show_read param, that can be used to hide read posts, but doesn't affect the ordering.

These were confusingly overlapping anyway.

@dessalines
Copy link
Member Author

Comes after #4606

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants