mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-05-31 17:53:59 +00:00
refactor
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
#include <functional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "data_generation/mock_generator.h"
|
#include "data_generation/mock_generator.h"
|
||||||
|
|
||||||
BreweryResult MockGenerator::GenerateBrewery(
|
auto MockGenerator::GenerateBrewery(const std::string& city_name,
|
||||||
const std::string& city_name, const std::string& country_name,
|
const std::string& country_name,
|
||||||
const std::string& region_context) {
|
const std::string& /*region_context*/)
|
||||||
const std::string location_key =
|
-> BreweryResult {
|
||||||
country_name.empty() ? city_name : city_name + "," + country_name;
|
const std::size_t hash = DeterministicHash(city_name, country_name);
|
||||||
const std::size_t hash =
|
|
||||||
region_context.empty() ? std::hash<std::string>{}(location_key)
|
|
||||||
: DeterministicHash(location_key, region_context);
|
|
||||||
|
|
||||||
BreweryResult result;
|
const std::string& adjective =
|
||||||
result.name = kBreweryAdjectives[hash % kBreweryAdjectives.size()] + " " +
|
kBreweryAdjectives.at(hash % kBreweryAdjectives.size());
|
||||||
kBreweryNouns[(hash / 7) % kBreweryNouns.size()];
|
const std::string& noun = kBreweryNouns.at((hash / 7) % kBreweryNouns.size());
|
||||||
result.description =
|
const std::string& base_description =
|
||||||
kBreweryDescriptions[(hash / 13) % kBreweryDescriptions.size()];
|
kBreweryDescriptions.at((hash / 13) % kBreweryDescriptions.size());
|
||||||
return result;
|
|
||||||
|
const std::string name = city_name + " " + adjective + " " + noun;
|
||||||
|
const std::string description =
|
||||||
|
base_description + " Based in " + city_name +
|
||||||
|
(country_name.empty() ? std::string(".")
|
||||||
|
: std::string(", ") + country_name + ".");
|
||||||
|
|
||||||
|
return {name, description};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user