This commit is contained in:
Aaron Po
2026-04-01 21:35:02 -04:00
parent 35aa7bc0df
commit 248a51b35f
6 changed files with 82 additions and 71 deletions

View File

@@ -3,8 +3,13 @@
#include "generator.h"
#include "json_loader.h"
#include <curl/curl.h>
#include <filesystem>
#include <spdlog/spdlog.h>
static bool FileExists(const std::string &filePath) {
return std::filesystem::exists(filePath);
}
int main(int argc, char *argv[]) {
try {
curl_global_init(CURL_GLOBAL_DEFAULT);
@@ -15,17 +20,25 @@ int main(int argc, char *argv[]) {
argc > 3 ? argv[3] : "c5eb7772"; // Default: stable 2026-03-28
std::string jsonPath = cacheDir + "/countries+states+cities.json";
std::string dbPath = cacheDir + "/biergarten-pipeline.db";
spdlog::info("\n[Pipeline] Downloading geographic data from GitHub...");
DataDownloader downloader;
downloader.DownloadCountriesDatabase(jsonPath, commit);
bool hasJsonCache = FileExists(jsonPath);
bool hasDbCache = FileExists(dbPath);
SqliteDatabase db;
spdlog::info("Initializing in-memory SQLite database...");
db.Initialize();
spdlog::info("Initializing SQLite database at {}...", dbPath);
db.Initialize(dbPath);
JsonLoader::LoadWorldCities(jsonPath, db);
if (hasDbCache && hasJsonCache) {
spdlog::info("[Pipeline] Cache hit: skipping download and parse");
} else {
spdlog::info("\n[Pipeline] Downloading geographic data from GitHub...");
DataDownloader downloader;
downloader.DownloadCountriesDatabase(jsonPath, commit);
JsonLoader::LoadWorldCities(jsonPath, db);
}
spdlog::info("Initializing brewery generator...");
LlamaBreweryGenerator generator;