change stats json formatting and add progress bars library

This commit is contained in:
2025-10-19 19:02:44 +02:00
parent 7a89c18d8e
commit ca7a2c51fb
2 changed files with 23 additions and 4 deletions

View File

@@ -26,11 +26,19 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(sqlite3pp)
FetchContent_Declare(
indicators
GIT_REPOSITORY https://github.com/p-ranav/indicators.git
GIT_TAG master
)
FetchContent_MakeAvailable(indicators)
file(GLOB SOURCES src/*.cpp)
add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
target_include_directories(${PROJECT_NAME} PUBLIC
include
${sqlite3pp_SOURCE_DIR}/headeronly_src
${indicators_SOURCE_DIR}/include
)
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite::SQLite3)

View File

@@ -7,12 +7,14 @@
#include <fstream>
#include "sqlite3pp.h"
// #include "indicators/cursor_control.hpp"
// #include "indicators/progress_bar.hpp" en faite c'est la requete SQL le plus lent
int main(int argc, char const *argv[])
{
auto begin = std::chrono::steady_clock::now();
sqlite3pp::database db("../uwu2x.db");
sqlite3pp::database db("../uwu2x-large.db");
sqlite3pp::query q(db, "SELECT DISTINCT identifier, strftime('%Y-%m-%d', date) FROM interaction ORDER BY date ASC;");
std::set<std::string> identifiers;
@@ -38,13 +40,22 @@ int main(int argc, char const *argv[])
}
std::ofstream f("../activity.json");
f << "{" << std::endl;
// f << "{" << std::endl;
// for (const auto &[key, val] : activity)
// {
// f << "\t\"" << key << "\": {\"u\": " << val.at("u") << ", \"n\": " << val.at("n") << "}," << std::endl;
// }
// f.seekp((long)f.tellp() - 2);
// f << std::endl << "}" << std::endl;
//{ date: "2025-09-09", u: 186, n: 80 }
f << "[" << std::endl;
for (const auto &[key, val] : activity)
{
f << "\t\"" << key << "\": {\"u\": " << val.at("u") << ", \"n\": " << val.at("n") << "}," << std::endl;
f << "\t{\"date\": \"" << key << "\", \"u\": " << val.at("u") << ", \"n\": " << val.at("n") << "}," << std::endl;
}
f.seekp((long)f.tellp() - 2);
f << std::endl << "}" << std::endl;
f << std::endl << "]" << std::endl;
auto end = std::chrono::steady_clock::now();