1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Increment the thumbnail version when cube_data or color_data is modified.

This commit is contained in:
MaxSignal
2026-06-29 17:01:52 +09:00
parent 0315548c95
commit 56aa7a2b38
3 changed files with 11 additions and 2 deletions

View File

@@ -1101,7 +1101,6 @@ impl <C: Clone + Send> super::User<C> for UserData {
to_update.name = oj_rc_database::sea_orm::ActiveValue::Set(new_name);
to_update.crf_id = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.crf_id);
to_update.movement_categories = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.movement_categories);
to_update.thumbnail_version = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.thumbnail_version);
to_update.total_robot_cpu = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_cpu);
to_update.total_cosmetic_cpu = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_cosmetic_cpu);
to_update.total_robot_ranking = oj_rc_database::sea_orm::ActiveValue::Set(slot_to_copy.total_robot_ranking);

View File

@@ -5,6 +5,12 @@ pub struct Id {
pub id: i32,
}
#[derive(FromQueryResult)]
pub struct IdAndThumbnailVersion {
pub id: i32,
pub thumbnail_version: i32,
}
#[derive(FromQueryResult)]
pub struct SingleColumn<T: sea_orm::TryGetable> {
pub column: T,

View File

@@ -359,13 +359,17 @@ impl Database {
let id_opt = crate::schema::garage::Entity::find()
.select_only()
.column(crate::schema::garage::Column::Id)
.column(crate::schema::garage::Column::ThumbnailVersion)
.filter(crate::schema::garage::Column::UserId.eq(user_id))
.filter(crate::schema::garage::Column::Slot.eq(slot))
.into_model::<crate::schema::common_query::Id>()
.into_model::<crate::schema::common_query::IdAndThumbnailVersion>()
.one(self.orm.as_ref())
.await?;
if let Some(id) = id_opt {
entity.id = sea_orm::ActiveValue::Set(id.id);
if entity.robot_data.is_set() || entity.colour_data.is_set() {
entity.thumbnail_version = sea_orm::ActiveValue::Set(id.thumbnail_version.wrapping_add(1));
}
Ok(Some(crate::schema::garage::Entity::update(entity)
.exec(self.orm.as_ref())
.await?))