order media so that latest added are top #660

Merged
Plume_migration_agent merged 2 commits from feature/621 into master 2019-08-28 09:37:04 +00:00

View file

@ -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)
igalic commented 2019-08-27 14:17:47 +00:00 (Migrated from github.com)
Review

is this guaranteed to be such?
do we have a create date anywhere?

is this guaranteed to be such? do we have a create date anywhere?
Review

we don't have date, and the ids we use are monotonic counter, unless we overflow that 64b signed counter (not likely to happen)

we don't have date, and the ids we use are monotonic counter, unless we overflow that 64b signed counter (not likely to happen)
igalic commented 2019-08-27 14:27:16 +00:00 (Migrated from github.com)
Review

i wonder if anyone expects that editing a media pushes it to the top again…

i wonder if anyone expects that editing a media pushes it to the top again…
elegaanz commented 2019-08-27 14:29:39 +00:00 (Migrated from github.com)
Review

We can't edit media information for the moment, so…

We can't edit media information for the moment, so…
igalic commented 2019-08-27 14:36:43 +00:00 (Migrated from github.com)
Review

well then… pushes [resolve] button

well then… *pushes [resolve] button*
.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)