From 4f0f56d7d7fd606cfbc3467813da18735ff6ad32 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sun, 19 Jul 2026 04:10:32 -0400 Subject: [PATCH] Formatted includes/services/database --- .../services/database/export_service.h | 54 ++++++------ .../services/database/sqlite_export_service.h | 82 +++++++++---------- .../services/database/sqlite_handle_types.h | 10 +-- .../database/sqlite_statement_helpers.h | 52 ++++++------ 4 files changed, 99 insertions(+), 99 deletions(-) diff --git a/tooling/pipeline/includes/services/database/export_service.h b/tooling/pipeline/includes/services/database/export_service.h index 9f4d85c2..dfa9bb9b 100644 --- a/tooling/pipeline/includes/services/database/export_service.h +++ b/tooling/pipeline/includes/services/database/export_service.h @@ -14,38 +14,38 @@ * @brief Interface for services that persist generated brewery records. */ class IExportService { - public: - IExportService() = default; - virtual ~IExportService() = default; + public: + IExportService() = default; + virtual ~IExportService() = default; - IExportService(const IExportService&) = delete; - IExportService& operator=(const IExportService&) = delete; - IExportService(IExportService&&) = delete; - IExportService& operator=(IExportService&&) = delete; + IExportService(const IExportService&) = delete; + IExportService& operator=(const IExportService&) = delete; + IExportService(IExportService&&) = delete; + IExportService& operator=(IExportService&&) = delete; - /** - * @brief Prepares the export destination for a new run. - */ - virtual void Initialize() = 0; + /** + * @brief Prepares the export destination for a new run. + */ + virtual void Initialize() = 0; - /** - * @brief Persists one generated brewery record. - * - * @param brewery Generated brewery payload to store. - */ - virtual uint64_t ProcessRecord(const BreweryRecord& brewery) = 0; + /** + * @brief Persists one generated brewery record. + * + * @param brewery Generated brewery payload to store. + */ + virtual uint64_t ProcessRecord(const BreweryRecord& brewery) = 0; - /** - * @brief Persists one generated user record. - * - * @param user Generated user payload to store. - */ - virtual uint64_t ProcessRecord(const UserRecord& user) = 0; + /** + * @brief Persists one generated user record. + * + * @param user Generated user payload to store. + */ + virtual uint64_t ProcessRecord(const UserRecord& user) = 0; - /** - * @brief Finalizes the export destination. - */ - virtual void Finalize() = 0; + /** + * @brief Finalizes the export destination. + */ + virtual void Finalize() = 0; }; #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_DATABASE_EXPORT_SERVICE_H_ diff --git a/tooling/pipeline/includes/services/database/sqlite_export_service.h b/tooling/pipeline/includes/services/database/sqlite_export_service.h index 258e0213..2eecc73b 100644 --- a/tooling/pipeline/includes/services/database/sqlite_export_service.h +++ b/tooling/pipeline/includes/services/database/sqlite_export_service.h @@ -20,54 +20,54 @@ * @brief Persists generated brewery records into a fresh SQLite database. */ class SqliteExportService final : public IExportService { - public: - explicit SqliteExportService(const ApplicationOptions& options); - ~SqliteExportService() override; + public: + explicit SqliteExportService(const ApplicationOptions& options); + ~SqliteExportService() override; - SqliteExportService(const SqliteExportService&) = delete; - SqliteExportService& operator=(const SqliteExportService&) = delete; - SqliteExportService(SqliteExportService&&) = delete; - SqliteExportService& operator=(SqliteExportService&&) = delete; + SqliteExportService(const SqliteExportService&) = delete; + SqliteExportService& operator=(const SqliteExportService&) = delete; + SqliteExportService(SqliteExportService&&) = delete; + SqliteExportService& operator=(SqliteExportService&&) = delete; - void Initialize() override; - uint64_t ProcessRecord(const BreweryRecord& brewery) override; - uint64_t ProcessRecord(const UserRecord& user) override; - void Finalize() override; + void Initialize() override; + uint64_t ProcessRecord(const BreweryRecord& brewery) override; + uint64_t ProcessRecord(const UserRecord& user) override; + void Finalize() override; - private: - using SqliteDatabaseHandle = - sqlite_export_service_internal::SqliteDatabaseHandle; - using SqliteStatementHandle = - sqlite_export_service_internal::SqliteStatementHandle; + private: + using SqliteDatabaseHandle = + sqlite_export_service_internal::SqliteDatabaseHandle; + using SqliteStatementHandle = + sqlite_export_service_internal::SqliteStatementHandle; - void InitializeSchema() const; - void PrepareStatements(); - void RollbackAndCloseNoThrow() noexcept; + void InitializeSchema() const; + void PrepareStatements(); + void RollbackAndCloseNoThrow() noexcept; - [[nodiscard]] std::filesystem::path BuildDatabasePath() const; - [[nodiscard]] static std::string BuildCityKey(const City& city); + [[nodiscard]] std::filesystem::path BuildDatabasePath() const; + [[nodiscard]] static std::string BuildCityKey(const City& city); - /** - * @brief Returns the row id for @p city, inserting it first if it has - * not already been seen during this run. - * - * Shared by both ProcessRecord() overloads so brewery and user addresses - * referencing the same city resolve to the same row. - */ - [[nodiscard]] sqlite3_int64 ResolveCityId(const City& city); + /** + * @brief Returns the row id for @p city, inserting it first if it has + * not already been seen during this run. + * + * Shared by both ProcessRecord() overloads so brewery and user addresses + * referencing the same city resolve to the same row. + */ + [[nodiscard]] sqlite3_int64 ResolveCityId(const City& city); - std::unique_ptr date_time_provider_; - std::filesystem::path output_path_; - std::string run_timestamp_utc_; - std::filesystem::path database_path_; - SqliteDatabaseHandle db_handle_; - SqliteStatementHandle insert_city_stmt_; - SqliteStatementHandle insert_brewery_stmt_; - SqliteStatementHandle insert_brewery_address_stmt_; - SqliteStatementHandle insert_user_stmt_; - SqliteStatementHandle insert_user_address_stmt_; - bool transaction_open_ = false; - std::unordered_map city_cache_; + std::unique_ptr date_time_provider_; + std::filesystem::path output_path_; + std::string run_timestamp_utc_; + std::filesystem::path database_path_; + SqliteDatabaseHandle db_handle_; + SqliteStatementHandle insert_city_stmt_; + SqliteStatementHandle insert_brewery_stmt_; + SqliteStatementHandle insert_brewery_address_stmt_; + SqliteStatementHandle insert_user_stmt_; + SqliteStatementHandle insert_user_address_stmt_; + bool transaction_open_ = false; + std::unordered_map city_cache_; }; #endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_DATABASE_SQLITE_EXPORT_SERVICE_H_ diff --git a/tooling/pipeline/includes/services/database/sqlite_handle_types.h b/tooling/pipeline/includes/services/database/sqlite_handle_types.h index a70377d7..d92eee0e 100644 --- a/tooling/pipeline/includes/services/database/sqlite_handle_types.h +++ b/tooling/pipeline/includes/services/database/sqlite_handle_types.h @@ -13,11 +13,11 @@ namespace sqlite_export_service_internal { struct SqliteDatabaseDeleter { - void operator()(sqlite3* handle) const noexcept; + void operator()(sqlite3* handle) const noexcept; }; struct SqliteStatementDeleter { - void operator()(sqlite3_stmt* statement) const noexcept; + void operator()(sqlite3_stmt* statement) const noexcept; }; using SqliteDatabaseHandle = std::unique_ptr; @@ -28,9 +28,9 @@ using SqliteStatementHandle = // N.B. indices are 1 based. template struct BoundParam { - int index; - T value; - std::string_view action; + int index; + T value; + std::string_view action; }; } // namespace sqlite_export_service_internal diff --git a/tooling/pipeline/includes/services/database/sqlite_statement_helpers.h b/tooling/pipeline/includes/services/database/sqlite_statement_helpers.h index 1cdc2365..fde53882 100644 --- a/tooling/pipeline/includes/services/database/sqlite_statement_helpers.h +++ b/tooling/pipeline/includes/services/database/sqlite_statement_helpers.h @@ -152,44 +152,44 @@ INSERT INTO user_addresses ( // sqlite3_bind_*() parameter indices are 1-based, matching the "?" // placeholder order in the SQL above. enum CityBindIndex { - kCityCityBindIndex = 1, - kCityStateProvinceBindIndex, - kCityIso31662BindIndex, - kCityCountryBindIndex, - kCityIso31661BindIndex, - kCityLanguagesBindIndex, - kCityPostalCodeCountryFormatRegexBindIndex, - kCityPostalCodeCityRegexJsonBindIndex, + kCityCityBindIndex = 1, + kCityStateProvinceBindIndex, + kCityIso31662BindIndex, + kCityCountryBindIndex, + kCityIso31661BindIndex, + kCityLanguagesBindIndex, + kCityPostalCodeCountryFormatRegexBindIndex, + kCityPostalCodeCityRegexJsonBindIndex, }; enum BreweryBindIndex { - kBreweryEnglishNameBindIndex = 1, - kBreweryEnglishDescriptionBindIndex, - kBreweryLocalNameBindIndex, - kBreweryLocalDescriptionBindIndex, + kBreweryEnglishNameBindIndex = 1, + kBreweryEnglishDescriptionBindIndex, + kBreweryLocalNameBindIndex, + kBreweryLocalDescriptionBindIndex, }; enum BreweryAddressBindIndex { - kBreweryAddressBreweryIdBindIndex = 1, - kBreweryAddressCityIdBindIndex, - kBreweryAddressPostalCodeBindIndex, + kBreweryAddressBreweryIdBindIndex = 1, + kBreweryAddressCityIdBindIndex, + kBreweryAddressPostalCodeBindIndex, }; enum UserBindIndex { - kUserFirstNameBindIndex = 1, - kUserLastNameBindIndex, - kUserGenderBindIndex, - kUserUsernameBindIndex, - kUserBioBindIndex, - kUserActivityWeightBindIndex, - kUserEmailBindIndex, - kUserDateOfBirthBindIndex, + kUserFirstNameBindIndex = 1, + kUserLastNameBindIndex, + kUserGenderBindIndex, + kUserUsernameBindIndex, + kUserBioBindIndex, + kUserActivityWeightBindIndex, + kUserEmailBindIndex, + kUserDateOfBirthBindIndex, }; enum UserAddressBindIndex { - kUserAddressUserIdBindIndex = 1, - kUserAddressCityIdBindIndex, - kUserAddressPostalCodeBindIndex, + kUserAddressUserIdBindIndex = 1, + kUserAddressCityIdBindIndex, + kUserAddressPostalCodeBindIndex, }; SqliteStatementHandle PrepareStatement(const SqliteDatabaseHandle& db_handle,