migrate wall to 11 rows

This commit is contained in:
2025-03-28 14:50:32 +01:00
parent 0751a9142b
commit 4ec35c7922
2 changed files with 28 additions and 6 deletions

View File

@@ -356,11 +356,7 @@ fn AttemptRadioGroup() -> impl IntoView {
attempt_radio_buttons.push(view! { <AttemptRadioButton on:click=onclick variant selected=ui_toggle /> });
}
view! {
<div class="gap-2 flex flex-row justify-evenly md:flex-col 2xl:flex-row">
{attempt_radio_buttons}
</div>
}
view! { <div class="gap-2 flex flex-col justify-evenly 2xl:flex-row">{attempt_radio_buttons}</div> }
}
#[component]
@@ -438,7 +434,7 @@ fn Wall() -> impl IntoView {
let style = {
let grid_rows = crate::css::grid_rows_n(wall.rows);
let grid_cols = crate::css::grid_cols_n(wall.cols);
let max_width = format!("{}vh", wall.rows as f64 / wall.cols as f64 * 100.);
let max_width = format!("{}vh", wall.cols as f64 / wall.rows as f64 * 100.);
format!("max-height: 100vh; max-width: {max_width}; {}", [grid_rows, grid_cols].join(" "))
};

View File

@@ -1,12 +1,38 @@
use super::db::Database;
use super::db::DatabaseOperationError;
use super::db::{self};
use crate::models;
use redb::ReadableTable;
#[tracing::instrument(skip_all, err)]
pub async fn run_migrations(db: &Database) -> Result<(), Box<dyn std::error::Error>> {
if is_at_version(db, 2).await? {
migrate_to_v3(db).await?;
}
migrate_wall(db).await?;
Ok(())
}
#[tracing::instrument(skip_all, err)]
pub async fn migrate_wall(db: &Database) -> Result<(), Box<dyn std::error::Error>> {
tracing::warn!("MIGRATING WALL");
db.write(|txn| {
let mut table = txn.open_table(db::current::TABLE_WALLS)?;
let wall = table
.get(models::WallUid(uuid::Uuid::parse_str("8a00ab39-89f5-4fc5-b9c6-f86b4c040f68").unwrap()))?
.map(|x| x.value());
if let Some(mut wall) = wall {
wall.rows = 11;
wall.holds.retain(|k, v| k.row < 11);
table.insert(wall.uid, wall)?;
}
Ok(())
})
.await?;
Ok(())
}