Formatted includes/services/enrichment

This commit is contained in:
Aaron Po
2026-07-19 04:10:32 -04:00
parent d9b10df436
commit 9bcf4c6879
3 changed files with 33 additions and 35 deletions

View File

@@ -14,16 +14,16 @@
* @brief Interface for services that can enrich a location with context. * @brief Interface for services that can enrich a location with context.
*/ */
class IEnrichmentService { class IEnrichmentService {
public: public:
virtual ~IEnrichmentService() = default; virtual ~IEnrichmentService() = default;
/** /**
* @brief Resolves contextual enrichment for a location. * @brief Resolves contextual enrichment for a location.
* *
* @param loc City to enrich. * @param loc City to enrich.
* @return Context text, or an empty string if unavailable. * @return Context text, or an empty string if unavailable.
*/ */
virtual std::string GetLocationContext(const City& loc) = 0; virtual std::string GetLocationContext(const City& loc) = 0;
}; };
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_ENRICHMENT_SERVICE_H_ #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_ENRICHMENT_SERVICE_H_

View File

@@ -14,9 +14,7 @@
* @brief Enrichment service that returns no context for any location. * @brief Enrichment service that returns no context for any location.
*/ */
class MockEnrichmentService final : public IEnrichmentService { class MockEnrichmentService final : public IEnrichmentService {
public: public:
std::string GetLocationContext(const City& /*loc*/) override { std::string GetLocationContext(const City& /*loc*/) override { return {}; }
return {};
}
}; };
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_ #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_MOCK_ENRICHMENT_H_

View File

@@ -19,30 +19,30 @@
* @brief Provides Wikipedia summary lookups backed by cached raw extracts. * @brief Provides Wikipedia summary lookups backed by cached raw extracts.
*/ */
class WikipediaEnrichmentService final : public IEnrichmentService { class WikipediaEnrichmentService final : public IEnrichmentService {
public: public:
/** /**
* @brief Creates a new Wikipedia service with the provided web client. * @brief Creates a new Wikipedia service with the provided web client.
*/ */
explicit WikipediaEnrichmentService(std::unique_ptr<WebClient> client, explicit WikipediaEnrichmentService(std::unique_ptr<WebClient> client,
std::shared_ptr<ILogger> logger); std::shared_ptr<ILogger> logger);
/** /**
* @brief Returns the Wikipedia-derived context for a location. * @brief Returns the Wikipedia-derived context for a location.
*/ */
[[nodiscard]] std::string GetLocationContext(const City& loc) override; [[nodiscard]] std::string GetLocationContext(const City& loc) override;
private: private:
std::string FetchExtract(std::string_view query); std::string FetchExtract(std::string_view query);
std::unique_ptr<WebClient> client_; std::unique_ptr<WebClient> client_;
std::shared_ptr<ILogger> logger_; std::shared_ptr<ILogger> logger_;
/** /**
* @brief Cache for raw Wikipedia query extracts, keyed by query string. * @brief Cache for raw Wikipedia query extracts, keyed by query string.
* *
* GetLocationContext() always queries "brewing" and reuses "beer in * GetLocationContext() always queries "brewing" and reuses "beer in
* {country}" for every city in that country, so caching avoids refetching * {country}" for every city in that country, so caching avoids refetching
* the same extract across locations in a run. * the same extract across locations in a run.
*/ */
std::unordered_map<std::string, std::string> extract_cache_; std::unordered_map<std::string, std::string> extract_cache_;
}; };
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_ #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_WIKIPEDIA_SERVICE_H_