mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 09:37:23 +00:00
Remove logger from JSON export
This commit is contained in:
@@ -19,13 +19,11 @@ class JsonLoader {
|
|||||||
public:
|
public:
|
||||||
/// @brief Parses a JSON array file and returns all location records.
|
/// @brief Parses a JSON array file and returns all location records.
|
||||||
static std::vector<Location> LoadLocations(
|
static std::vector<Location> LoadLocations(
|
||||||
const std::filesystem::path& filepath,
|
const std::filesystem::path& filepath);
|
||||||
std::shared_ptr<ILogger> logger = nullptr);
|
|
||||||
|
|
||||||
/// @brief Parses a JSON array file and returns all persona records.
|
/// @brief Parses a JSON array file and returns all persona records.
|
||||||
static std::vector<UserPersona> LoadPersonas(
|
static std::vector<UserPersona> LoadPersonas(
|
||||||
const std::filesystem::path& filepath,
|
const std::filesystem::path& filepath);
|
||||||
std::shared_ptr<ILogger> logger = nullptr);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Parses the names-by-country fixture pair into a sampling-capable
|
* @brief Parses the names-by-country fixture pair into a sampling-capable
|
||||||
@@ -36,8 +34,7 @@ class JsonLoader {
|
|||||||
*/
|
*/
|
||||||
static NamesByCountry LoadNamesByCountry(
|
static NamesByCountry LoadNamesByCountry(
|
||||||
const std::filesystem::path& forenames_filepath,
|
const std::filesystem::path& forenames_filepath,
|
||||||
const std::filesystem::path& surnames_filepath,
|
const std::filesystem::path& surnames_filepath);
|
||||||
std::shared_ptr<ILogger> logger = nullptr);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_
|
#endif // BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void BiergartenPipelineOrchestrator::GenerateUsers(
|
|||||||
.message = "=== SAMPLE USER GENERATION ==="});
|
.message = "=== SAMPLE USER GENERATION ==="});
|
||||||
|
|
||||||
const std::vector<UserPersona> personas =
|
const std::vector<UserPersona> personas =
|
||||||
JsonLoader::LoadPersonas("personas.json", logger_);
|
JsonLoader::LoadPersonas("personas.json");
|
||||||
|
|
||||||
if (personas.empty()) {
|
if (personas.empty()) {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
@@ -104,7 +104,7 @@ void BiergartenPipelineOrchestrator::GenerateUsers(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NamesByCountry names_by_country = JsonLoader::LoadNamesByCountry(
|
const NamesByCountry names_by_country = JsonLoader::LoadNamesByCountry(
|
||||||
"forenames-by-country.json", "surnames-by-country.json", logger_);
|
"forenames-by-country.json", "surnames-by-country.json");
|
||||||
|
|
||||||
std::mt19937 rng(std::random_device{}());
|
std::mt19937 rng(std::random_device{}());
|
||||||
std::uniform_int_distribution<size_t> persona_dist(0, personas.size() - 1);
|
std::uniform_int_distribution<size_t> persona_dist(0, personas.size() - 1);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ BiergartenPipelineOrchestrator::QueryCitiesWithCountries() {
|
|||||||
|
|
||||||
const std::filesystem::path locations_path = "locations.json";
|
const std::filesystem::path locations_path = "locations.json";
|
||||||
|
|
||||||
auto all_locations = JsonLoader::LoadLocations(locations_path, logger_);
|
auto all_locations = JsonLoader::LoadLocations(locations_path);
|
||||||
|
|
||||||
const size_t sample_count = std::min(
|
const size_t sample_count = std::min(
|
||||||
static_cast<size_t>(application_options_.pipeline.location_count),
|
static_cast<size_t>(application_options_.pipeline.location_count),
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ std::string ReadFirstOfStringArray(const boost::json::object& object,
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::vector<Location> JsonLoader::LoadLocations(
|
std::vector<Location> JsonLoader::LoadLocations(
|
||||||
const std::filesystem::path& filepath, std::shared_ptr<ILogger> logger) {
|
const std::filesystem::path& filepath) {
|
||||||
const boost::json::value root = ParseJsonFile(filepath, "locations");
|
const boost::json::value root = ParseJsonFile(filepath, "locations");
|
||||||
|
|
||||||
if (!root.is_array()) {
|
if (!root.is_array()) {
|
||||||
@@ -140,7 +140,7 @@ std::vector<Location> JsonLoader::LoadLocations(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UserPersona> JsonLoader::LoadPersonas(
|
std::vector<UserPersona> JsonLoader::LoadPersonas(
|
||||||
const std::filesystem::path& filepath, std::shared_ptr<ILogger> logger) {
|
const std::filesystem::path& filepath) {
|
||||||
const boost::json::value root = ParseJsonFile(filepath, "personas");
|
const boost::json::value root = ParseJsonFile(filepath, "personas");
|
||||||
|
|
||||||
if (!root.is_array()) {
|
if (!root.is_array()) {
|
||||||
@@ -171,8 +171,7 @@ std::vector<UserPersona> JsonLoader::LoadPersonas(
|
|||||||
|
|
||||||
NamesByCountry JsonLoader::LoadNamesByCountry(
|
NamesByCountry JsonLoader::LoadNamesByCountry(
|
||||||
const std::filesystem::path& forenames_filepath,
|
const std::filesystem::path& forenames_filepath,
|
||||||
const std::filesystem::path& surnames_filepath,
|
const std::filesystem::path& surnames_filepath) {
|
||||||
std::shared_ptr<ILogger> logger) {
|
|
||||||
const boost::json::value forenames_root =
|
const boost::json::value forenames_root =
|
||||||
ParseJsonFile(forenames_filepath, "forenames-by-country");
|
ParseJsonFile(forenames_filepath, "forenames-by-country");
|
||||||
const boost::json::value surnames_root =
|
const boost::json::value surnames_root =
|
||||||
|
|||||||
Reference in New Issue
Block a user