mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 01:54:43 +00:00
Formatted src/biergarten_pipeline_orchestrator
This commit is contained in:
@@ -24,7 +24,8 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
|
|||||||
[this, &skipped_count](
|
[this, &skipped_count](
|
||||||
const EnrichedCity& enriched_city) -> std::optional<BreweryRecord> {
|
const EnrichedCity& enriched_city) -> std::optional<BreweryRecord> {
|
||||||
try {
|
try {
|
||||||
const BreweryResult brewery = generator_->GenerateBrewery(enriched_city);
|
const BreweryResult brewery =
|
||||||
|
generator_->GenerateBrewery(enriched_city);
|
||||||
const std::string postal_code =
|
const std::string postal_code =
|
||||||
postal_code_service_->GeneratePostalCode(enriched_city.location);
|
postal_code_service_->GeneratePostalCode(enriched_city.location);
|
||||||
return BreweryRecord{
|
return BreweryRecord{
|
||||||
@@ -34,10 +35,10 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
|
|||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
++skipped_count;
|
++skipped_count;
|
||||||
|
|
||||||
logger_->Log(
|
logger_->Log({.level = LogLevel::Warn,
|
||||||
{.level = LogLevel::Warn,
|
|
||||||
.phase = PipelinePhase::BreweryAndBeerGeneration,
|
.phase = PipelinePhase::BreweryAndBeerGeneration,
|
||||||
.message = std::format("[Pipeline] Skipping city '{}' ({}): brewery "
|
.message = std::format(
|
||||||
|
"[Pipeline] Skipping city '{}' ({}): brewery "
|
||||||
"generation failed: {}",
|
"generation failed: {}",
|
||||||
enriched_city.location.city,
|
enriched_city.location.city,
|
||||||
enriched_city.location.country, e.what())});
|
enriched_city.location.country, e.what())});
|
||||||
@@ -45,13 +46,14 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto export_record = [this, &export_failed_count](
|
const auto export_record =
|
||||||
const BreweryRecord& record) {
|
[this, &export_failed_count](const BreweryRecord& record) {
|
||||||
try {
|
try {
|
||||||
exporter_->ProcessRecord(record);
|
exporter_->ProcessRecord(record);
|
||||||
} catch (const std::exception& export_exception) {
|
} catch (const std::exception& export_exception) {
|
||||||
++export_failed_count;
|
++export_failed_count;
|
||||||
logger_->Log({.level = LogLevel::Warn,
|
logger_->Log(
|
||||||
|
{.level = LogLevel::Warn,
|
||||||
.phase = PipelinePhase::BreweryAndBeerGeneration,
|
.phase = PipelinePhase::BreweryAndBeerGeneration,
|
||||||
.message = std::format(
|
.message = std::format(
|
||||||
"[Pipeline] Generated brewery for '{}' ({}) "
|
"[Pipeline] Generated brewery for '{}' ({}) "
|
||||||
@@ -62,7 +64,8 @@ void BiergartenPipelineOrchestrator::GenerateBreweries(
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (const EnrichedCity& enriched_city : cities) {
|
for (const EnrichedCity& enriched_city : cities) {
|
||||||
const std::optional<BreweryRecord> record = generate_record(enriched_city);
|
const std::optional<BreweryRecord> record =
|
||||||
|
generate_record(enriched_city);
|
||||||
if (!record.has_value()) {
|
if (!record.has_value()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ std::string Sanitize(std::string_view value) {
|
|||||||
|
|
||||||
std::string BuildEmail(const Name& name,
|
std::string BuildEmail(const Name& name,
|
||||||
std::unordered_set<std::string>& used_local_parts) {
|
std::unordered_set<std::string>& used_local_parts) {
|
||||||
const std::string base =
|
const std::string base = std::format("{}.{}", Sanitize(name.first_name),
|
||||||
std::format("{}.{}", Sanitize(name.first_name), Sanitize(name.last_name));
|
Sanitize(name.last_name));
|
||||||
|
|
||||||
std::string local_part = base;
|
std::string local_part = base;
|
||||||
uint32_t suffix = 1;
|
uint32_t suffix = 1;
|
||||||
@@ -147,12 +147,13 @@ void BiergartenPipelineOrchestrator::GenerateUsers(
|
|||||||
};
|
};
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
++skipped_count;
|
++skipped_count;
|
||||||
logger_->Log({.level = LogLevel::Warn,
|
logger_->Log(
|
||||||
|
{.level = LogLevel::Warn,
|
||||||
.phase = PipelinePhase::UserGeneration,
|
.phase = PipelinePhase::UserGeneration,
|
||||||
.message = std::format(
|
.message = std::format("[Pipeline] Skipping city '{}' ({}): "
|
||||||
"[Pipeline] Skipping city '{}' ({}): "
|
|
||||||
"user generation failed: {}",
|
"user generation failed: {}",
|
||||||
city.location.city, city.location.country, e.what())});
|
city.location.city, city.location.country,
|
||||||
|
e.what())});
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -164,7 +165,8 @@ void BiergartenPipelineOrchestrator::GenerateUsers(
|
|||||||
} catch (const std::exception& export_exception) {
|
} catch (const std::exception& export_exception) {
|
||||||
++export_failed_count;
|
++export_failed_count;
|
||||||
|
|
||||||
logger_->Log({.level = LogLevel::Warn,
|
logger_->Log(
|
||||||
|
{.level = LogLevel::Warn,
|
||||||
.phase = PipelinePhase::UserGeneration,
|
.phase = PipelinePhase::UserGeneration,
|
||||||
.message = std::format(
|
.message = std::format(
|
||||||
"[Pipeline] Generated user for '{}' ({}) but "
|
"[Pipeline] Generated user for '{}' ({}) but "
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
#include "services/curated_data/curated_json_data_service.h"
|
#include "services/curated_data/curated_json_data_service.h"
|
||||||
#include "services/logging/logger.h"
|
#include "services/logging/logger.h"
|
||||||
|
|
||||||
std::vector<City>
|
std::vector<City> BiergartenPipelineOrchestrator::QueryLocations() {
|
||||||
BiergartenPipelineOrchestrator::QueryLocations() {
|
|
||||||
logger_->Log({.level = LogLevel::Info,
|
logger_->Log({.level = LogLevel::Info,
|
||||||
.phase = PipelinePhase::Startup,
|
.phase = PipelinePhase::Startup,
|
||||||
.message = "=== GEOGRAPHIC DATA OVERVIEW ==="});
|
.message = "=== GEOGRAPHIC DATA OVERVIEW ==="});
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ bool BiergartenPipelineOrchestrator::Run() {
|
|||||||
size_t skipped_count = 0;
|
size_t skipped_count = 0;
|
||||||
for (auto& city : cities) {
|
for (auto& city : cities) {
|
||||||
try {
|
try {
|
||||||
std::string region_context = context_service_->GetLocationContext(city);
|
std::string region_context =
|
||||||
|
context_service_->GetLocationContext(city);
|
||||||
|
|
||||||
enriched.push_back(
|
enriched.push_back(
|
||||||
EnrichedCity{.location = std::move(city),
|
EnrichedCity{.location = std::move(city),
|
||||||
|
|||||||
Reference in New Issue
Block a user