fix: use gear model column for brew card grinder display
The grinder_model field was computed by splitting the concatenated "make model" string on the first space, which broke for multi-word brand names like "Weber Workshops". Fetch g_grinder.model directly from the database instead.
This commit is contained in:
parent
da206c1938
commit
08c1ef05cf
3 changed files with 10 additions and 4 deletions
|
|
@ -97,6 +97,7 @@ pub struct BrewWithDetails {
|
||||||
pub roast_slug: String,
|
pub roast_slug: String,
|
||||||
pub roaster_slug: String,
|
pub roaster_slug: String,
|
||||||
pub grinder_name: String,
|
pub grinder_name: String,
|
||||||
|
pub grinder_model: String,
|
||||||
pub brewer_name: String,
|
pub brewer_name: String,
|
||||||
pub filter_paper_name: Option<String>,
|
pub filter_paper_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ const BASE_SELECT: &str = r"
|
||||||
r.name as roast_name, r.slug as roast_slug,
|
r.name as roast_name, r.slug as roast_slug,
|
||||||
rr.name as roaster_name, rr.slug as roaster_slug,
|
rr.name as roaster_name, rr.slug as roaster_slug,
|
||||||
(g_grinder.make || ' ' || g_grinder.model) as grinder_name,
|
(g_grinder.make || ' ' || g_grinder.model) as grinder_name,
|
||||||
|
g_grinder.model as grinder_model,
|
||||||
(g_brewer.make || ' ' || g_brewer.model) as brewer_name,
|
(g_brewer.make || ' ' || g_brewer.model) as brewer_name,
|
||||||
(g_fp.make || ' ' || g_fp.model) as filter_paper_name
|
(g_fp.make || ' ' || g_fp.model) as filter_paper_name
|
||||||
FROM brews br
|
FROM brews br
|
||||||
|
|
@ -118,6 +119,7 @@ impl SqlBrewRepository {
|
||||||
roast_slug: record.roast_slug,
|
roast_slug: record.roast_slug,
|
||||||
roaster_slug: record.roaster_slug,
|
roaster_slug: record.roaster_slug,
|
||||||
grinder_name: record.grinder_name,
|
grinder_name: record.grinder_name,
|
||||||
|
grinder_model: record.grinder_model,
|
||||||
brewer_name: record.brewer_name,
|
brewer_name: record.brewer_name,
|
||||||
filter_paper_name: record.filter_paper_name,
|
filter_paper_name: record.filter_paper_name,
|
||||||
}
|
}
|
||||||
|
|
@ -325,6 +327,7 @@ struct BrewWithDetailsRecord {
|
||||||
roaster_name: String,
|
roaster_name: String,
|
||||||
roaster_slug: String,
|
roaster_slug: String,
|
||||||
grinder_name: String,
|
grinder_name: String,
|
||||||
|
grinder_model: String,
|
||||||
brewer_name: String,
|
brewer_name: String,
|
||||||
filter_paper_name: Option<String>,
|
filter_paper_name: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,7 @@ impl BrewView {
|
||||||
roaster_slug: brew.roaster_slug,
|
roaster_slug: brew.roaster_slug,
|
||||||
coffee_weight: format_weight(brew.brew.coffee_weight),
|
coffee_weight: format_weight(brew.brew.coffee_weight),
|
||||||
grinder_id: brew.brew.grinder_id.into_inner(),
|
grinder_id: brew.brew.grinder_id.into_inner(),
|
||||||
grinder_model: brew
|
grinder_model: brew.grinder_model,
|
||||||
.grinder_name
|
|
||||||
.split_once(' ')
|
|
||||||
.map_or_else(|| brew.grinder_name.clone(), |(_, model)| model.to_string()),
|
|
||||||
grinder_name: brew.grinder_name,
|
grinder_name: brew.grinder_name,
|
||||||
grind_setting: format!("{:.1}", brew.brew.grind_setting),
|
grind_setting: format!("{:.1}", brew.brew.grind_setting),
|
||||||
brewer_id: brew.brew.brewer_id.into_inner(),
|
brewer_id: brew.brew.brewer_id.into_inner(),
|
||||||
|
|
@ -225,6 +222,9 @@ pub struct BrewDetailView {
|
||||||
// Map
|
// Map
|
||||||
pub map_countries: String,
|
pub map_countries: String,
|
||||||
pub map_max: u32,
|
pub map_max: u32,
|
||||||
|
// Slugs (for breadcrumbs)
|
||||||
|
pub roaster_slug: String,
|
||||||
|
pub roast_slug: String,
|
||||||
// Dates
|
// Dates
|
||||||
pub created_date: String,
|
pub created_date: String,
|
||||||
pub created_time: String,
|
pub created_time: String,
|
||||||
|
|
@ -256,6 +256,8 @@ impl BrewDetailView {
|
||||||
id: brew.brew.id.to_string(),
|
id: brew.brew.id.to_string(),
|
||||||
roast_name: brew.roast_name,
|
roast_name: brew.roast_name,
|
||||||
roaster_name: brew.roaster_name,
|
roaster_name: brew.roaster_name,
|
||||||
|
roaster_slug: roaster.slug.clone(),
|
||||||
|
roast_slug: roast.slug.clone(),
|
||||||
origin: coffee.origin,
|
origin: coffee.origin,
|
||||||
origin_flag: coffee.origin_flag,
|
origin_flag: coffee.origin_flag,
|
||||||
region: coffee.region,
|
region: coffee.region,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue