File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -297,3 +297,20 @@ pub async fn update_with_json_moved(
297297
298298 Ok ( the_mod)
299299}
300+
301+ /// Used when first version goes from pending to accepted.
302+ /// Makes it so versions that stay a lot in pending appear at the top of the newly created lists
303+ pub async fn touch_created_at ( id : & str , conn : & mut PgConnection ) -> Result < ( ) , ApiError > {
304+ sqlx:: query!(
305+ "UPDATE mods
306+ SET updated_at = NOW()
307+ WHERE id = $1" ,
308+ id
309+ )
310+ . execute ( conn)
311+ . await
312+ . inspect_err ( |e| log:: error!( "Failed to touch updated_at for mod {}: {}" , id, e) )
313+ . or ( Err ( ApiError :: DbError ) ) ?;
314+
315+ Ok ( ( ) )
316+ }
Original file line number Diff line number Diff line change @@ -460,6 +460,11 @@ pub async fn update_version(
460460 if old_status == ModVersionStatusEnum :: Pending
461461 && version. status == ModVersionStatusEnum :: Accepted
462462 {
463+ if approved_count == 0 {
464+ // Used to push new mods to the top of the "Recently created" list
465+ mods:: touch_created_at ( & the_mod. id , & mut tx) . await ?;
466+ }
467+
463468 let bytes = mod_zip:: download_mod_hash_comp (
464469 & version. download_link ,
465470 & version. hash ,
You can’t perform that action at this time.
0 commit comments