mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-12-23 18:40:34 +00:00
order media so that latest added are top (#660)
* order media so that latest added are top partial fix for #621 * also order paginated medias
This commit is contained in:
parent
ddbec3f204
commit
d46af6fe5b
1 changed files with 9 additions and 1 deletions
|
@ -62,7 +62,14 @@ impl MediaCategory {
|
|||
impl Media {
|
||||
insert!(medias, NewMedia);
|
||||
get!(medias);
|
||||
list_by!(medias, for_user, owner_id as i32);
|
||||
|
||||
pub fn for_user(conn: &Connection, owner: i32) -> Result<Vec<Media>> {
|
||||
medias::table
|
||||
.filter(medias::owner_id.eq(owner))
|
||||
.order(medias::id.desc())
|
||||
.load::<Self>(conn)
|
||||
.map_err(Error::from)
|
||||
}
|
||||
|
||||
pub fn list_all_medias(conn: &Connection) -> Result<Vec<Media>> {
|
||||
medias::table.load::<Media>(conn).map_err(Error::from)
|
||||
|
@ -75,6 +82,7 @@ impl Media {
|
|||
) -> Result<Vec<Media>> {
|
||||
medias::table
|
||||
.filter(medias::owner_id.eq(user.id))
|
||||
.order(medias::id.desc())
|
||||
.offset(i64::from(min))
|
||||
.limit(i64::from(max - min))
|
||||
.load::<Media>(conn)
|
||||
|
|
Loading…
Reference in a new issue