Skip to content

Commit

Permalink
Merge pull request #10 from arieldk1212/dev
Browse files Browse the repository at this point in the history
dev --> main Merge
  • Loading branch information
arieldk1212 authored Feb 5, 2025
2 parents 6eb3b9f + 186b7bf commit 04c8a9f
Show file tree
Hide file tree
Showing 44 changed files with 573 additions and 626 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:
brew install docker docker-compose docker-buildx
- name: Build Dockerfile
run: docker-buildx build . --platform linux/arm64
# run: COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build
# run: docker-buildx build . --platform linux/arm64
run: COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build
14 changes: 5 additions & 9 deletions .github/workflows/macos-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
initdb --locale=C -D /opt/homebrew/var/postgres@15
pg_ctl -D /opt/homebrew/var/postgres@15 start
createuser -s postgres
psql -U postgres -c "CREATE ROLE arielkriheli WITH LOGIN PASSWORD 'password';"
psql -U postgres -c "ALTER ROLE arielkriheli CREATEDB;"
psql -U postgres -c "CREATE DATABASE live_view_test OWNER arielkriheli;"
psql -U postgres -c "CREATE ROLE ci WITH LOGIN PASSWORD 'password';"
psql -U postgres -c "ALTER ROLE ci CREATEDB;"
psql -U postgres -c "CREATE DATABASE live_view_ci_test OWNER ci;"
- name: Install vcpkg
run: |
Expand All @@ -49,10 +49,6 @@ jobs:
run: make -j 4
working-directory: ${{ github.workspace }}/build

# - name: Test Specific
# run: ctest --output-on-failure --extra-verbose -R UUID
# working-directory: ${{ github.workspace }}/build

- name: Run Tests
- name: Run Unit Tests
run: ctest --output-on-failure --extra-verbose
working-directory: ${{ github.workspace }}/build
working-directory: ${{ github.workspace }}/build
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_INCLUDE_CURRENT_DIR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") # g for lldb help
if (false)
add_definitions(-DENABLE_LOGGING)
endif()

if (APPLE)
set(CMAKE_TOOLCHAIN_FILE "/Users/$ENV{USER}/Library/vcpkg/scripts/buildsystems/vcpkg.cmake")
Expand All @@ -24,14 +21,16 @@ find_package(OpenSSL REQUIRED)
find_package(PostgreSQL REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(libpqxx CONFIG REQUIRED)
find_package(benchmark REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)

list(APPEND project_libraries
libpqxx::pqxx
PostgreSQL::PostgreSQL
OpenSSL::SSL
OpenSSL::Crypto
libpqxx::pqxx
PostgreSQL::PostgreSQL
spdlog::spdlog
benchmark::benchmark
nlohmann_json::nlohmann_json
)

Expand Down
13 changes: 13 additions & 0 deletions configs/ci-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"TEST_DATABASE": {
"username": "ci",
"password": "password",
"host": "localhost",
"port": "5432",
"dbname": "live_view_ci_test"
},

"LOGGING": {
"path": ""
}
}
4 changes: 1 addition & 3 deletions config.json → configs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
"port": "5432",
"dbname": "arielkriheli"
},

"TEST_DATABASE": {
"username": "arielkriheli",
"password": "password",
"host": "localhost",
"port": "5432",
"dbname": "live_view_test"
},

"LOGGING": {
"PATH": ""
"path": ""
}
}
File renamed without changes.
17 changes: 0 additions & 17 deletions inc/Core/Address.h

This file was deleted.

2 changes: 1 addition & 1 deletion inc/Core/Conditions/Types/RoadCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class RoadCondition : public Condition {
public:
virtual ~RoadCondition() = 0;
virtual ~RoadCondition();

void ConditionType() override { m_RoadConditionType = "Road Condition"; }
virtual void RoadConditionType() = 0;
Expand Down
Empty file.
35 changes: 0 additions & 35 deletions inc/Core/Entity.h

This file was deleted.

2 changes: 1 addition & 1 deletion inc/Core/Geo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ class Geo {
std::string m_Latitude;
};

#endif // GEO_H
#endif
5 changes: 5 additions & 0 deletions inc/Core/Interface/InstanceLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

// TODO: write this into database, when accessible.

/**
* @brief wont be done now, not until we figure out elastic search and kibana structure.
*
*/

class InstanceLogger {
public:
virtual ~InstanceLogger();
Expand Down
58 changes: 53 additions & 5 deletions inc/Core/Responses/Response.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,57 @@
#ifndef RESPONSE_H
#ifndef RESPONSE_H
#define RESPONSE_H

// INFO: this class is all about the response classes from different classes across the project.
// meaning -> from db model a model returns a certain reponse from the db, due to that we will
// create a class that will handle different reponse cases and return the right response, i.e:
// virtual DBResponse WriteToDB(); -> it will hold data, codes, general info about the response.
// Entity
// TODO: add logic for the data separation from the full address to entity
// block. INFO: when i get the address from the Address Class, it will be passed
// down to Entity and the logic of the address separation to entities will be
// dealt here, meaning i probably want to change the Entity Ctor to the address
// itself, and the separate to Entities ( Data Structures ). INFO: the address
// class will inherit from entity due to the need use of the private entity
// members and their functionality.

#include "Config/Logger.h"

#include <chrono>
#include <pqxx/pqxx>

template <typename ResType> class Response {
public:
using Clock = std::chrono::high_resolution_clock;
using DoubleDuration = std::chrono::duration<double>;

public:
virtual ~Response() = 0;

virtual const std::string GetResponseQuery() const = 0;
virtual const size_t GetResponseSize() const = 0;

virtual DoubleDuration RunBenchmark(std::function<void()> Func) = 0;
virtual const std::string ResponseType() = 0;
};

class DBResponse : Response<pqxx::result> {
public:
explicit DBResponse(const pqxx::result &ResponseData);
explicit DBResponse(pqxx::result &&ResponseData);

[[nodiscard]] const std::string GetResponseQuery() const override {
return m_ResponseData.query();
}
[[nodiscard]] const size_t GetResponseSize() const override { return m_ResponseSize; }

DoubleDuration RunBenchmark(std::function<void()> Func) override;
const std::string ResponseType() override { return "Response: Database"; }

private:
size_t m_ResponseSize;
pqxx::result m_ResponseData;
};

/**
* @brief
* DBResponse x = Manager->AddModel; -> copy ctor
* return DBReponse(CreateTable(Args...)); -> ctor
*/

#endif
31 changes: 0 additions & 31 deletions inc/Core/Type.h

This file was deleted.

31 changes: 31 additions & 0 deletions inc/Models/AddressModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef ADDRESS_MODEL_H
#define ADDRESS_MODEL_H

#include "BaseModel.h"
#include "Config/DatabaseCommands.h"

class AddressModel : BaseModel {
public:
explicit AddressModel(std::shared_ptr<DatabaseManager> &Manager);
~AddressModel() override;

const std::string GetTableName() const override { return m_TableName; }

pqxx::result Init() override;
pqxx::result Add(const StringUnMap &Fields) override;
// pqxx::result Update(const StringUnMap &Fields) override;
// pqxx::result Delete(const StringUnMap &Fields) override;

private:
std::shared_ptr<DatabaseManager> m_DatabaseManager;

private:
std::string m_TableName;
StringUnMap m_AddressFields = {
{"addressname",
DatabaseCommandToString(DatabaseFieldCommands::VarChar100Field)},
{"addressnumber",
DatabaseCommandToString(DatabaseFieldCommands::IntField)}};
};

#endif
23 changes: 23 additions & 0 deletions inc/Models/BaseModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef BASE_MODEL_H
#define BASE_MODEL_H

#include "Config/DatabaseManager.h"
#include <nlohmann/json.hpp>
#include <pqxx/pqxx>

using Json = nlohmann::json;

class BaseModel {
public:
virtual ~BaseModel() = 0;
virtual const std::string GetTableName() const = 0;
virtual pqxx::result Init() = 0;
virtual pqxx::result Add(const StringUnMap &Fields) = 0;
// virtual pqxx::result Update(const StringUnMap &Fields) = 0;
// virtual pqxx::result Delete(const StringUnMap &Fields) = 0;

// virtual Json SerializeModel(const std::string &Data) = 0;
// virtual std::string DeserializeModel(const Json &JsonData) = 0;
};

#endif
Loading

0 comments on commit 04c8a9f

Please sign in to comment.