Added topm id and row number and ui changes.

This commit is contained in:
2026-02-07 19:08:13 +01:00
parent 05b073812c
commit 088734f237
11 changed files with 176 additions and 74 deletions
+7 -2
View File
@@ -21,6 +21,7 @@ pub struct Article {
pub bio_origin: Option<String>,
pub allergens_text: Option<String>,
pub bio_info: Option<String>,
pub topm_id: Option<String>,
}
fn from_postgres_row_small(row: PgRow) -> Article {
@@ -37,6 +38,7 @@ fn from_postgres_row_small(row: PgRow) -> Article {
bio_origin: row.get(8),
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
}
}
@@ -67,6 +69,7 @@ async fn from_postgres_row(row: PgRow, pool: PgPool) -> Article {
bio_origin: row.get(8),
allergens_text: row.get(9),
bio_info: row.get(10),
topm_id: row.get(11),
}
}
@@ -137,9 +140,10 @@ pub async fn insert_article(article: &Article, pool: PgPool) -> Option<Article>
args.add(&article.bio_origin);
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
let statement = format!(
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *",
"INSERT INTO {} (name, bio, origin, description, ingredients, default_unit_id, mhd, bio_origin, allergens_text, bio_info, topm_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *",
"article",
);
@@ -176,9 +180,10 @@ pub async fn update_article(article_id: i64, article: &Article, pool: PgPool) ->
args.add(&article.bio_origin);
args.add(&article.allergens_text);
args.add(&article.bio_info);
args.add(&article.topm_id);
let statement = format!(
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11 WHERE id = $1 RETURNING *",
"UPDATE {} SET name = $2, bio = $3, origin = $4, description = $5, ingredients = $6, default_unit_id = $7, mhd = $8, bio_origin = $9, allergens_text = $10, bio_info = $11, topm_id = $12 WHERE id = $1 RETURNING *",
"article",
);
+6 -2
View File
@@ -16,6 +16,7 @@ pub struct Variant {
pub unit: Unit,
pub label: Option<Label>,
pub variant_description: Option<String>,
pub topm_row: Option<String>,
}
async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant {
@@ -39,6 +40,7 @@ async fn from_postgres_row(row: PgRow, pool: &PgPool) -> Variant {
unit: row.get(7),
label: label,
variant_description: row.get(9),
topm_row: row.get(10),
}
}
@@ -94,9 +96,10 @@ pub async fn insert_variant(article_id: i64, variant: &Variant, pool: PgPool) ->
args.add(&variant.unit);
args.add(label_id);
args.add(&variant.variant_description);
args.add(&variant.topm_row);
let statement = format!(
"INSERT INTO {} (article_id, weight, ean, name, description, ingredients, unit_id, label_id, variant_description) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *",
"INSERT INTO {} (article_id, weight, ean, name, description, ingredients, unit_id, label_id, variant_description, topm_row) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *",
"variant",
);
@@ -139,11 +142,12 @@ pub async fn update_variant(variant_id: i64, variant: &Variant, pool: PgPool) ->
args.add(&variant.unit);
args.add(label_id);
args.add(&variant.variant_description);
args.add(&variant.topm_row);
info!("Variant: {:#?}", variant);
let statement = format!(
"UPDATE {} SET weight = $2, ean = $3, name = $4, description = $5, ingredients = $6, unit_id = $7, label_id = $8, variant_description = $9 WHERE id = $1 RETURNING *",
"UPDATE {} SET weight = $2, ean = $3, name = $4, description = $5, ingredients = $6, unit_id = $7, label_id = $8, variant_description = $9, topm_row = $10 WHERE id = $1 RETURNING *",
"variant",
);