This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from The-B1T-Foundation/added_metrics
Added metrics & MT
- Loading branch information
Showing
16 changed files
with
491 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...e/business_logic/controller/config/tg_root_user_config/tg_root_user_config_controller.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#include "tg_root_user_config_controller.hpp" | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
std::optional<ATG_Root_User_Config> ATG_Root_User_Config_Controller::Load_Config() | ||
{ | ||
char* tg_root_user{ std::getenv("TG_ROOT_USER") }; | ||
if (!tg_root_user) | ||
{ | ||
return std::nullopt; | ||
} | ||
|
||
return ATG_Root_User_Config{ strtoll(tg_root_user, nullptr, 10) }; | ||
} |
38 changes: 38 additions & 0 deletions
38
...e/business_logic/controller/config/tg_root_user_config/tg_root_user_config_controller.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#pragma once | ||
|
||
#include <optional> | ||
#include <cstdlib> | ||
|
||
#include <model/config/tg_root_user_config/tg_root_user_config_model.hpp> | ||
|
||
class ATG_Root_User_Config_Controller | ||
{ | ||
public: | ||
constexpr ATG_Root_User_Config_Controller() = default; | ||
constexpr ~ATG_Root_User_Config_Controller() = default; | ||
|
||
static std::optional<ATG_Root_User_Config> Load_Config(); | ||
}; |
49 changes: 49 additions & 0 deletions
49
source/business_logic/controller/db/metrics_db/metrics_db_controller.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#include "metrics_db_controller.hpp" | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
AMetrics_DB_Controller::AMetrics_DB_Controller(const ADB_Config& db_cfg) : | ||
ABase_DB_Controller{ db_cfg, "metrics_data" } | ||
{ } | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
void AMetrics_DB_Controller::Set_Metrics(const SMetrics& metrics) | ||
{ | ||
Exec_Query(std::format(R"(INSERT INTO {} (start_req, profile_req, pr_game_req, math_game_req, help_req, about_project_req, definition_req, date) VALUES ('{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}'))", Table_Name, metrics.Start_Request_Count, metrics.Profile_Request_Count, metrics.Pr_Game_Request_Count, metrics.Math_Game_Request_Count, metrics.Help_Request_Count, metrics.About_Project_Request_Count, metrics.Definition_Request_Count, metrics.Get_Current_Date())); | ||
} | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
SMetrics AMetrics_DB_Controller::Get_Metrics(std::int64_t metrics_id) | ||
{ | ||
auto response{ Exec_Query(std::format(R"(SELECT start_req, profile_req, pr_game_req, math_game_req, help_req, about_project_req, definition_req, date FROM {} WHERE id = '{}')", Table_Name, metrics_id)) }; | ||
return SMetrics{ response[0][0].as<std::int64_t>(), response[0][1].as<std::int64_t>(), response[0][2].as<std::int64_t>(), response[0][3].as<std::int64_t>(), response[0][4].as<std::int64_t>(), response[0][5].as<std::int64_t>(), response[0][6].as<std::int64_t>(), response[0][7].as<std::string>() }; | ||
} | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
std::int64_t AMetrics_DB_Controller::Get_Available_Metrics_Count() | ||
{ | ||
auto response{ Exec_Query(std::format(R"(SELECT MAX(id) FROM {})", Table_Name)) }; | ||
return response[0][0].as<std::int64_t>(); | ||
} |
38 changes: 38 additions & 0 deletions
38
source/business_logic/controller/db/metrics_db/metrics_db_controller.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#pragma once | ||
|
||
#include <controller/db/base_db/base_db_controller.hpp> | ||
#include <model/metrics/metrics_model.hpp> | ||
|
||
class AMetrics_DB_Controller : public ABase_DB_Controller | ||
{ | ||
public: | ||
explicit AMetrics_DB_Controller(const ADB_Config& db_cfg); | ||
~AMetrics_DB_Controller() override = default; | ||
|
||
void Set_Metrics(const SMetrics& metrics); | ||
SMetrics Get_Metrics(std::int64_t metrics_id); | ||
std::int64_t Get_Available_Metrics_Count(); | ||
}; |
35 changes: 35 additions & 0 deletions
35
source/business_logic/model/config/tg_root_user_config/tg_root_user_config_model.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#include "tg_root_user_config_model.hpp" | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
ATG_Root_User_Config::ATG_Root_User_Config(std::int64_t root_id) : | ||
Root_Id{ root_id } | ||
{ } | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
std::int64_t ATG_Root_User_Config::Get_Root_Id() const | ||
{ | ||
return Root_Id; | ||
} |
38 changes: 38 additions & 0 deletions
38
source/business_logic/model/config/tg_root_user_config/tg_root_user_config_model.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#pragma once | ||
|
||
#include <cstdint> | ||
|
||
class ATG_Root_User_Config | ||
{ | ||
public: | ||
explicit ATG_Root_User_Config(std::int64_t root_id); | ||
constexpr ~ATG_Root_User_Config() = default; | ||
|
||
[[nodiscard]] std::int64_t Get_Root_Id() const; | ||
|
||
private: | ||
std::int64_t Root_Id; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// MIT License | ||
|
||
// Copyright (c) 2024 The B1T Foundation | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
|
||
#include "metrics_model.hpp" | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
SMetrics::SMetrics() : | ||
Start_Request_Count{}, Profile_Request_Count{}, Pr_Game_Request_Count{}, Math_Game_Request_Count{}, Help_Request_Count{}, About_Project_Request_Count{}, Definition_Request_Count{}, Current_Date{} | ||
{ } | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
SMetrics::SMetrics(std::int64_t start_request_count, std::int64_t profile_request_count, std::int64_t pr_game_request_count, std::int64_t math_game_request_count, std::int64_t help_request_count, std::int64_t about_project_request_count, std::int64_t definition_request_count, std::string current_date) : | ||
Start_Request_Count{ start_request_count }, Profile_Request_Count{ profile_request_count }, Pr_Game_Request_Count{ pr_game_request_count }, Math_Game_Request_Count{ math_game_request_count }, Help_Request_Count{ help_request_count }, About_Project_Request_Count{ about_project_request_count }, Definition_Request_Count{ definition_request_count }, Current_Date{ std::move(current_date) } | ||
{ } | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
void SMetrics::Set_Current_Date() | ||
{ | ||
std::chrono::system_clock::time_point time_point{ std::chrono::system_clock::now() }; | ||
Current_Date = std::format("{:%Y.%m.%d %H:%M}", time_point); | ||
} | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
const std::string& SMetrics::Get_Current_Date() const | ||
{ | ||
return Current_Date; | ||
} | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
void SMetrics::Clear() | ||
{ | ||
Start_Request_Count = 0; | ||
Profile_Request_Count = 0; | ||
Pr_Game_Request_Count = 0; | ||
Math_Game_Request_Count = 0; | ||
Help_Request_Count = 0; | ||
About_Project_Request_Count = 0; | ||
Definition_Request_Count = 0; | ||
Current_Date = " "; | ||
} |
Oops, something went wrong.