refactor(cafes): remove notes field from Cafe entity
- Add migration 0014 to drop the notes column from cafes table - Remove notes from domain structs, repository, view model, CLI, routes - Remove notes textarea/column from web templates - Update bootstrap script and all test files
This commit is contained in:
parent
ca4d382086
commit
fb31d0a0c4
16 changed files with 19 additions and 76 deletions
1
migrations/0014_remove_cafe_notes.sql
Normal file
1
migrations/0014_remove_cafe_notes.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE cafes DROP COLUMN notes;
|
||||
|
|
@ -426,8 +426,7 @@ fi
|
|||
--country "United Kingdom" \
|
||||
--latitude 51.5055 \
|
||||
--longitude -0.0910 \
|
||||
--website "https://www.monmouthcoffee.co.uk" \
|
||||
--notes "Iconic Borough Market cafe; queues around the block for a reason."
|
||||
--website "https://www.monmouthcoffee.co.uk"
|
||||
|
||||
# London - Prufrock Coffee
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -436,8 +435,7 @@ fi
|
|||
--country "United Kingdom" \
|
||||
--latitude 51.5246 \
|
||||
--longitude -0.1098 \
|
||||
--website "https://www.prufrockcoffee.com" \
|
||||
--notes "Award-winning Leather Lane cafe with stellar barista training programme."
|
||||
--website "https://www.prufrockcoffee.com"
|
||||
|
||||
# Madrid - Hola Coffee
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -446,8 +444,7 @@ fi
|
|||
--country "Spain" \
|
||||
--latitude 40.4285 \
|
||||
--longitude -3.7025 \
|
||||
--website "https://www.holacoffee.es" \
|
||||
--notes "Pioneering specialty coffee in the Malasaña neighbourhood."
|
||||
--website "https://www.holacoffee.es"
|
||||
|
||||
# Madrid - Toma Café
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -455,8 +452,7 @@ fi
|
|||
--city "Madrid" \
|
||||
--country "Spain" \
|
||||
--latitude 40.4260 \
|
||||
--longitude -3.7075 \
|
||||
--notes "Relaxed Malasaña spot known for excellent filter and warm atmosphere."
|
||||
--longitude -3.7075
|
||||
|
||||
# Berlin - The Barn
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -465,8 +461,7 @@ fi
|
|||
--country "Germany" \
|
||||
--latitude 52.5298 \
|
||||
--longitude 13.4020 \
|
||||
--website "https://thebarn.de" \
|
||||
--notes "Light-roast pioneer in Prenzlauer Berg; their own roastery supplies the cafe."
|
||||
--website "https://thebarn.de"
|
||||
|
||||
# Berlin - Companion Coffee
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -475,8 +470,7 @@ fi
|
|||
--country "Germany" \
|
||||
--latitude 52.4952 \
|
||||
--longitude 13.4188 \
|
||||
--website "https://www.companion.coffee" \
|
||||
--notes "Minimalist Neukölln cafe with a curated rotating menu of guest roasters."
|
||||
--website "https://www.companion.coffee"
|
||||
|
||||
# Munich - Man Versus Machine
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -485,8 +479,7 @@ fi
|
|||
--country "Germany" \
|
||||
--latitude 48.1310 \
|
||||
--longitude 11.5690 \
|
||||
--website "https://www.mvsmcoffee.de" \
|
||||
--notes "Munich's specialty flagship; roasts in-house and competes internationally."
|
||||
--website "https://www.mvsmcoffee.de"
|
||||
|
||||
# Munich - Vits der Kaffee
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -495,8 +488,7 @@ fi
|
|||
--country "Germany" \
|
||||
--latitude 48.1353 \
|
||||
--longitude 11.5741 \
|
||||
--website "https://www.vfrischekaffee.de" \
|
||||
--notes "Modern cafe near Viktualienmarkt with thoughtful sourcing and seasonal offerings."
|
||||
--website "https://www.vfrischekaffee.de"
|
||||
|
||||
# Bristol - Full Court Press
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -505,8 +497,7 @@ fi
|
|||
--country "United Kingdom" \
|
||||
--latitude 51.4543 \
|
||||
--longitude -2.5930 \
|
||||
--website "https://www.fullcourtpress.coffee" \
|
||||
--notes "Bristol institution on Broad Street; brunch and specialty coffee done right."
|
||||
--website "https://www.fullcourtpress.coffee"
|
||||
|
||||
# Bristol - Small Street Espresso
|
||||
./target/debug/brewlog cafe add \
|
||||
|
|
@ -514,8 +505,7 @@ fi
|
|||
--city "Bristol" \
|
||||
--country "United Kingdom" \
|
||||
--latitude 51.4540 \
|
||||
--longitude -2.5955 \
|
||||
--notes "Tiny takeaway bar with a cult following for its espresso and flat whites."
|
||||
--longitude -2.5955
|
||||
|
||||
# ============================================================================
|
||||
# Cups - 1 to 3 cups per cafe, pairing roasts with cafes visited
|
||||
|
|
|
|||
|
|
@ -156,8 +156,7 @@ pub(crate) async fn update_cafe(
|
|||
|| payload.country.is_some()
|
||||
|| payload.latitude.is_some()
|
||||
|| payload.longitude.is_some()
|
||||
|| payload.website.is_some()
|
||||
|| payload.notes.is_some();
|
||||
|| payload.website.is_some();
|
||||
|
||||
if !has_changes {
|
||||
return Err(AppError::validation("no changes provided").into());
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ pub struct Cafe {
|
|||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
pub website: Option<String>,
|
||||
pub notes: Option<String>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
|
@ -27,7 +26,6 @@ pub struct NewCafe {
|
|||
pub latitude: f64,
|
||||
pub longitude: f64,
|
||||
pub website: Option<String>,
|
||||
pub notes: Option<String>,
|
||||
}
|
||||
|
||||
impl NewCafe {
|
||||
|
|
@ -36,7 +34,6 @@ impl NewCafe {
|
|||
self.city = self.city.trim().to_string();
|
||||
self.country = self.country.trim().to_string();
|
||||
self.website = normalize_optional_field(self.website);
|
||||
self.notes = normalize_optional_field(self.notes);
|
||||
self
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +61,6 @@ pub struct UpdateCafe {
|
|||
pub latitude: Option<f64>,
|
||||
pub longitude: Option<f64>,
|
||||
pub website: Option<String>,
|
||||
pub notes: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ impl BackupService {
|
|||
|
||||
async fn export_cafes(&self) -> anyhow::Result<Vec<Cafe>> {
|
||||
let records = sqlx::query_as::<_, CafeRecord>(
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at FROM cafes ORDER BY id",
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, created_at, updated_at FROM cafes ORDER BY id",
|
||||
)
|
||||
.fetch_all(&self.pool)
|
||||
.await
|
||||
|
|
@ -350,7 +350,7 @@ impl BackupService {
|
|||
) -> anyhow::Result<()> {
|
||||
for cafe in cafes {
|
||||
sqlx::query(
|
||||
"INSERT INTO cafes (id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
"INSERT INTO cafes (id, name, slug, city, country, latitude, longitude, website, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
)
|
||||
.bind(i64::from(cafe.id))
|
||||
.bind(&cafe.name)
|
||||
|
|
@ -360,7 +360,6 @@ impl BackupService {
|
|||
.bind(cafe.latitude)
|
||||
.bind(cafe.longitude)
|
||||
.bind(cafe.website.as_deref())
|
||||
.bind(cafe.notes.as_deref())
|
||||
.bind(cafe.created_at)
|
||||
.bind(cafe.updated_at)
|
||||
.execute(&mut **tx)
|
||||
|
|
@ -577,7 +576,6 @@ struct CafeRecord {
|
|||
latitude: f64,
|
||||
longitude: f64,
|
||||
website: Option<String>,
|
||||
notes: Option<String>,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
|
@ -593,7 +591,6 @@ impl CafeRecord {
|
|||
latitude: self.latitude,
|
||||
longitude: self.longitude,
|
||||
website: self.website,
|
||||
notes: self.notes,
|
||||
created_at: self.created_at,
|
||||
updated_at: self.updated_at,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ impl SqlCafeRepository {
|
|||
latitude,
|
||||
longitude,
|
||||
website,
|
||||
notes,
|
||||
created_at,
|
||||
updated_at,
|
||||
} = record;
|
||||
|
|
@ -59,7 +58,6 @@ impl SqlCafeRepository {
|
|||
latitude,
|
||||
longitude,
|
||||
website,
|
||||
notes,
|
||||
created_at,
|
||||
updated_at,
|
||||
}
|
||||
|
|
@ -115,8 +113,8 @@ impl CafeRepository for SqlCafeRepository {
|
|||
let now = Utc::now();
|
||||
|
||||
let record = query_as::<_, CafeRecord>(
|
||||
"INSERT INTO cafes (name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\
|
||||
RETURNING id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at",
|
||||
"INSERT INTO cafes (name, slug, city, country, latitude, longitude, website, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)\
|
||||
RETURNING id, name, slug, city, country, latitude, longitude, website, created_at, updated_at",
|
||||
)
|
||||
.bind(&new_cafe.name)
|
||||
.bind(&slug)
|
||||
|
|
@ -125,7 +123,6 @@ impl CafeRepository for SqlCafeRepository {
|
|||
.bind(new_cafe.latitude)
|
||||
.bind(new_cafe.longitude)
|
||||
.bind(new_cafe.website.as_deref())
|
||||
.bind(new_cafe.notes.as_deref())
|
||||
.bind(now)
|
||||
.bind(now)
|
||||
.fetch_one(&mut *tx)
|
||||
|
|
@ -170,7 +167,7 @@ impl CafeRepository for SqlCafeRepository {
|
|||
|
||||
async fn get(&self, id: CafeId) -> Result<Cafe, RepositoryError> {
|
||||
let record = query_as::<_, CafeRecord>(
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at FROM cafes WHERE id = ?",
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, created_at, updated_at FROM cafes WHERE id = ?",
|
||||
)
|
||||
.bind(i64::from(id))
|
||||
.fetch_optional(&self.pool)
|
||||
|
|
@ -185,7 +182,7 @@ impl CafeRepository for SqlCafeRepository {
|
|||
|
||||
async fn get_by_slug(&self, slug: &str) -> Result<Cafe, RepositoryError> {
|
||||
let record = query_as::<_, CafeRecord>(
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at FROM cafes WHERE slug = ?",
|
||||
"SELECT id, name, slug, city, country, latitude, longitude, website, created_at, updated_at FROM cafes WHERE slug = ?",
|
||||
)
|
||||
.bind(slug)
|
||||
.fetch_optional(&self.pool)
|
||||
|
|
@ -206,7 +203,7 @@ impl CafeRepository for SqlCafeRepository {
|
|||
use crate::infrastructure::repositories::pagination::SearchFilter;
|
||||
|
||||
let order_clause = Self::order_clause(request);
|
||||
let base_query = "SELECT id, name, slug, city, country, latitude, longitude, website, notes, created_at, updated_at FROM cafes";
|
||||
let base_query = "SELECT id, name, slug, city, country, latitude, longitude, website, created_at, updated_at FROM cafes";
|
||||
let count_query = "SELECT COUNT(*) FROM cafes";
|
||||
let sf = search.and_then(|t| SearchFilter::new(t, vec!["name", "city", "country"]));
|
||||
|
||||
|
|
@ -232,7 +229,6 @@ impl CafeRepository for SqlCafeRepository {
|
|||
push_update_field!(builder, sep, "latitude", changes.latitude);
|
||||
push_update_field!(builder, sep, "longitude", changes.longitude);
|
||||
push_update_field!(builder, sep, "website", changes.website);
|
||||
push_update_field!(builder, sep, "notes", changes.notes);
|
||||
let _ = sep;
|
||||
|
||||
builder.push(" WHERE id = ");
|
||||
|
|
@ -276,7 +272,6 @@ struct CafeRecord {
|
|||
latitude: f64,
|
||||
longitude: f64,
|
||||
website: Option<String>,
|
||||
notes: Option<String>,
|
||||
created_at: DateTime<Utc>,
|
||||
updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ pub struct AddCafeCommand {
|
|||
pub longitude: f64,
|
||||
#[arg(long)]
|
||||
pub website: Option<String>,
|
||||
#[arg(long)]
|
||||
pub notes: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn add_cafe(client: &BrewlogClient, command: AddCafeCommand) -> Result<()> {
|
||||
|
|
@ -57,7 +55,6 @@ pub async fn add_cafe(client: &BrewlogClient, command: AddCafeCommand) -> Result
|
|||
latitude: command.latitude,
|
||||
longitude: command.longitude,
|
||||
website: command.website,
|
||||
notes: command.notes,
|
||||
};
|
||||
|
||||
let cafe = client.cafes().create(&payload).await?;
|
||||
|
|
@ -87,8 +84,6 @@ pub struct UpdateCafeCommand {
|
|||
pub longitude: Option<f64>,
|
||||
#[arg(long)]
|
||||
pub website: Option<String>,
|
||||
#[arg(long)]
|
||||
pub notes: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn update_cafe(client: &BrewlogClient, command: UpdateCafeCommand) -> Result<()> {
|
||||
|
|
@ -99,7 +94,6 @@ pub async fn update_cafe(client: &BrewlogClient, command: UpdateCafeCommand) ->
|
|||
latitude: command.latitude,
|
||||
longitude: command.longitude,
|
||||
website: command.website,
|
||||
notes: command.notes,
|
||||
};
|
||||
|
||||
let cafe = client
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ pub struct CafeView {
|
|||
pub has_website: bool,
|
||||
pub website_url: String,
|
||||
pub website_label: String,
|
||||
pub notes: String,
|
||||
pub created_at: String,
|
||||
pub created_at_sort_key: i64,
|
||||
}
|
||||
|
|
@ -28,7 +27,6 @@ impl From<Cafe> for CafeView {
|
|||
latitude,
|
||||
longitude,
|
||||
website,
|
||||
notes,
|
||||
created_at,
|
||||
updated_at: _,
|
||||
} = cafe;
|
||||
|
|
@ -53,7 +51,6 @@ impl From<Cafe> for CafeView {
|
|||
has_website,
|
||||
website_url: website.clone(),
|
||||
website_label: website,
|
||||
notes: notes.unwrap_or_else(|| "This cafe has no notes yet.".to_string()),
|
||||
created_at: created_at_label,
|
||||
created_at_sort_key,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,5 @@ block content %}
|
|||
<dd class="text-right">{{ cafe.created_at }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="text-sm text-stone-600">{{ cafe.notes }}</p>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -312,15 +312,6 @@
|
|||
placeholder="-122.4194"
|
||||
/>
|
||||
</label>
|
||||
<label class="sm:col-span-2 flex flex-col gap-1 text-sm">
|
||||
<span class="text-stone-700">Notes</span>
|
||||
<textarea
|
||||
name="notes"
|
||||
rows="3"
|
||||
class="input-field"
|
||||
placeholder="Atmosphere, speciality drinks, opening hours..."
|
||||
></textarea>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<button
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
{% call table::sortable_header("Added", "created-at", navigator, "#cafe-list") %}
|
||||
{% call table::sortable_header("Name", "name", navigator, "#cafe-list") %}
|
||||
{% call table::sortable_header("Location", "country", navigator, "#cafe-list") %}
|
||||
<th scope="col" class="mobile-hidden px-4 py-3">Notes</th>
|
||||
<th scope="col" class="px-4 py-3 text-right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -50,7 +49,6 @@
|
|||
<div class="hidden md:block text-xs text-stone-500">{{ cafe.city }}</div>
|
||||
</td>
|
||||
<td data-label="City" class="px-4 py-3 whitespace-nowrap md:hidden">{{ cafe.city }}</td>
|
||||
<td data-label="Notes" class="mobile-hidden px-4 py-3 text-sm text-stone-600">{{ cafe.notes }}</td>
|
||||
<td data-label="" class="px-4 py-3 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<a
|
||||
|
|
|
|||
|
|
@ -226,7 +226,6 @@ async fn populate_test_data(db: &TestDb) -> (Roaster, Roast, Bag, Gear, Gear, Ge
|
|||
latitude: 51.5246,
|
||||
longitude: -0.1098,
|
||||
website: Some("https://prufrockcoffee.com".to_string()),
|
||||
notes: Some("Award-winning espresso bar".to_string()),
|
||||
})
|
||||
.await
|
||||
.expect("failed to create cafe");
|
||||
|
|
@ -378,7 +377,6 @@ async fn backup_and_restore_round_trip() {
|
|||
assert_eq!(restored_cafe.latitude, cafe.latitude);
|
||||
assert_eq!(restored_cafe.longitude, cafe.longitude);
|
||||
assert_eq!(restored_cafe.website, cafe.website);
|
||||
assert_eq!(restored_cafe.notes, cafe.notes);
|
||||
|
||||
// Timeline events
|
||||
let target_timeline = list_all_timeline_events(target.timeline_repo.as_ref()).await;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ async fn creating_a_cafe_returns_a_201_for_valid_data() {
|
|||
latitude: 37.7749,
|
||||
longitude: -122.4194,
|
||||
website: Some("https://bluebottlecoffee.com".to_string()),
|
||||
notes: Some("Great pour-over".to_string()),
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
@ -36,7 +35,6 @@ async fn creating_a_cafe_returns_a_201_for_valid_data() {
|
|||
cafe.website,
|
||||
Some("https://bluebottlecoffee.com".to_string())
|
||||
);
|
||||
assert_eq!(cafe.notes, Some("Great pour-over".to_string()));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
|
@ -51,7 +49,6 @@ async fn creating_a_cafe_persists_the_data() {
|
|||
latitude: 48.8566,
|
||||
longitude: 2.3522,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
@ -87,7 +84,6 @@ async fn creating_a_cafe_requires_authentication() {
|
|||
latitude: 51.5074,
|
||||
longitude: -0.1278,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
@ -163,7 +159,6 @@ async fn listing_cafes_returns_a_200_with_multiple_cafes() {
|
|||
latitude: 51.5074,
|
||||
longitude: -0.1278,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let cafe2 = NewCafe {
|
||||
|
|
@ -173,7 +168,6 @@ async fn listing_cafes_returns_a_200_with_multiple_cafes() {
|
|||
latitude: 52.52,
|
||||
longitude: 13.405,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
client
|
||||
|
|
@ -250,7 +244,6 @@ async fn updating_a_cafe_returns_a_200_for_valid_data() {
|
|||
latitude: None,
|
||||
longitude: None,
|
||||
website: Some("https://updated.com".to_string()),
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
@ -282,7 +275,6 @@ async fn updating_a_cafe_with_no_changes_returns_a_400() {
|
|||
latitude: None,
|
||||
longitude: None,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
@ -308,7 +300,6 @@ async fn updating_a_nonexistent_cafe_returns_a_404() {
|
|||
latitude: None,
|
||||
longitude: None,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
|
|||
|
|
@ -814,7 +814,6 @@ async fn cafes_create_with_datastar_header_returns_fragment() {
|
|||
latitude: 51.5074,
|
||||
longitude: -0.1278,
|
||||
website: None,
|
||||
notes: None,
|
||||
};
|
||||
|
||||
let response = client
|
||||
|
|
|
|||
|
|
@ -445,7 +445,6 @@ pub async fn create_default_cafe(app: &TestApp) -> Cafe {
|
|||
latitude: 37.7749,
|
||||
longitude: -122.4194,
|
||||
website: Some("https://bluebottlecoffee.com".to_string()),
|
||||
notes: Some("Great pour-over".to_string()),
|
||||
},
|
||||
)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -476,7 +476,6 @@ async fn creating_a_cafe_surfaces_on_the_timeline() {
|
|||
latitude: 51.4545,
|
||||
longitude: -2.5879,
|
||||
website: Some("https://example.com".to_string()),
|
||||
notes: None,
|
||||
},
|
||||
)
|
||||
.await;
|
||||
|
|
|
|||
Loading…
Reference in a new issue