fix: traiter le premier lot de tickets
Refs #4 #5 #6 #9 #12 #16 #18 #20
This commit is contained in:
parent
3f82acbbd8
commit
04cbe54dd1
14 changed files with 87 additions and 12 deletions
|
|
@ -375,6 +375,16 @@ final class DemoDataService
|
|||
$animalIds[$name] = (int) $db->lastInsertId();
|
||||
}
|
||||
|
||||
$publish = $db->prepare(
|
||||
"UPDATE animals SET website_published=1,website_description=? WHERE id=? AND adoption_availability='available'",
|
||||
);
|
||||
foreach (['Moka', 'Pixel', 'Caramel', 'Plume', 'Lune', 'Soleil'] as $name) {
|
||||
$publish->execute([
|
||||
'Fiche fictive publiée pour découvrir le fonctionnement du site public de démonstration.',
|
||||
$animalIds[$name],
|
||||
]);
|
||||
}
|
||||
|
||||
$db->prepare('INSERT INTO litters(mother_id,birth_date,notes) VALUES(?,?,?)')->execute([
|
||||
$animalIds['Plume'],
|
||||
$animals[6][3],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,12 @@ final class GeoService
|
|||
return null;
|
||||
}
|
||||
|
||||
// Cache DB
|
||||
// Garde-fou pour les bases anciennes dans lesquelles la table de cache
|
||||
// n'avait jamais été créée par une migration dédiée.
|
||||
$db->exec(
|
||||
"CREATE TABLE IF NOT EXISTS geocode_cache (q TEXT PRIMARY KEY, lat REAL, lng REAL, raw_json TEXT, fetched_at TEXT NOT NULL DEFAULT (datetime('now')))",
|
||||
);
|
||||
|
||||
$st = $db->prepare('SELECT lat,lng FROM geocode_cache WHERE q=:q LIMIT 1');
|
||||
$st->execute([':q' => $q]);
|
||||
$row = $st->fetch(PDO::FETCH_ASSOC);
|
||||
|
|
@ -17,7 +22,6 @@ final class GeoService
|
|||
return ['lat' => (float) $row['lat'], 'lng' => (float) $row['lng']];
|
||||
}
|
||||
|
||||
// Nominatim (OpenStreetMap) — respecter l'usage: User-Agent + requêtes raisonnables
|
||||
$url = 'https://nominatim.openstreetmap.org/search?format=jsonv2&limit=1&q=' . rawurlencode($q);
|
||||
|
||||
$ch = curl_init($url);
|
||||
|
|
@ -43,7 +47,6 @@ final class GeoService
|
|||
|
||||
$json = json_decode($body, true);
|
||||
if (!is_array($json) || empty($json[0]['lat']) || empty($json[0]['lon'])) {
|
||||
// Stocker "vide" en cache évite de spammer
|
||||
$db->prepare(
|
||||
"INSERT OR REPLACE INTO geocode_cache(q,lat,lng,raw_json,fetched_at) VALUES(:q,NULL,NULL,:raw,datetime('now'))",
|
||||
)->execute([':q' => $q, ':raw' => $body]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue