It would be interesting to sort posts in different ways then the current Active, Hot, New, … Criteria. I searched the backend-codebase and found this enum:
crates/db_shema_file/src/enums.rs
...
/// The post sort types. See here for descriptions: https://join-lemmy.org/docs/en/users/03-votes-and-ranking.html
pub enum PostSortType {
#[default]
Active,
Hot,
New,
Old,
Top,
MostComments,
NewComments,
Controversial,
Scaled,
}
and the database uses this for example in crates/db_views/post/src/impls.rs
NewComments => pq.then_order_by(key::newest_comment_time_at),
I have multiple questions regarding this:
- lets say I add another variant to this enum, and add some functionality to it in the backend, would the frontend dropdown-menu in the UI update and show it? (guess this is not the case, since frontend and backend live in different folders.
- here is a sample sorting url for the Scaled sort type “https://lemmy.world/?dataType=Post&listingType=All&sort=Scaled”. This will trigger the backend to query the database and receive a sorted list of items to display as hypertext to my understanding.
- since Diesel implements the Database Query I would not need to write any postgresql?
- would other instances support my new sorting method or only my own modified codebase instance? I guess its the latter.
A first simple idea: Add a “random” sort type, that sorts post in random order. Some uuid or hashed timestamp of a post could work for this.
You must log in or register to comment.
You’ll need to have a familiarity with rust and postgres before adding a random sort. If you open up a github issue on this tho, we’d be able help out.