-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: return data version on each query
- Loading branch information
1 parent
4209258
commit be5c886
Showing
8 changed files
with
104 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef SILO_INCLUDE_SILO_COMMON_DATAVERSION_H_ | ||
#define SILO_INCLUDE_SILO_COMMON_DATAVERSION_H_ | ||
|
||
#include <string> | ||
|
||
class DataVersion { | ||
public: | ||
explicit DataVersion(const std::string& data_version = ""); | ||
[[nodiscard]] std::string toString() const; | ||
|
||
static std::string mineDataVersion(); | ||
|
||
private: | ||
std::string data_version; | ||
}; | ||
|
||
#endif // SILO_INCLUDE_SILO_COMMON_DATAVERSION_H_ |
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
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
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,16 @@ | ||
#include "silo/common/data_version.h" | ||
|
||
#include <chrono> | ||
|
||
std::string DataVersion::mineDataVersion() { | ||
const auto now = std::chrono::system_clock::now(); | ||
const auto now_as_time_t = std::chrono::system_clock::to_time_t(now); | ||
return std::to_string(now_as_time_t); | ||
} | ||
|
||
DataVersion::DataVersion(const std::string& data_version) | ||
: data_version(data_version) {} | ||
|
||
std::string DataVersion::toString() const { | ||
return data_version; | ||
} |
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,19 @@ | ||
#include "silo/common/data_version.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
TEST(DataVersion, shouldMineDataVersionFromUnixTime) { | ||
const auto mined_version = DataVersion::mineDataVersion(); | ||
EXPECT_EQ(mined_version.size(), 10); | ||
EXPECT_EQ(mined_version[0], '1'); | ||
} | ||
|
||
TEST(DataVersion, shouldConstructFromVersionString) { | ||
const auto version = DataVersion("1234567890"); | ||
EXPECT_EQ(version.toString(), "1234567890"); | ||
} | ||
|
||
TEST(DataVersion, shouldConstructWithDefaultVersion) { | ||
const auto version = DataVersion(); | ||
EXPECT_EQ(version.toString(), ""); | ||
} |
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
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
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