From 92cdee4e55a76db0b340964a5f366239de26edca Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 3 Feb 2024 16:52:15 +0100 Subject: [PATCH] Code improvements Added crapview lib --- logdoctor/CMakeLists.txt | 1 + logdoctor/modules/crapview/modules/lib.h | 68 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 logdoctor/modules/crapview/modules/lib.h diff --git a/logdoctor/CMakeLists.txt b/logdoctor/CMakeLists.txt index cd500a14..d666ecbb 100644 --- a/logdoctor/CMakeLists.txt +++ b/logdoctor/CMakeLists.txt @@ -122,6 +122,7 @@ set(PROJECT_SOURCES modules/crapview/crapview.h modules/crapview/crapview.cpp + modules/crapview/modules/lib.h modules/crapview/modules/filters.h modules/crapview/modules/filters.cpp modules/crapview/modules/query.h diff --git a/logdoctor/modules/crapview/modules/lib.h b/logdoctor/modules/crapview/modules/lib.h new file mode 100644 index 00000000..573aba03 --- /dev/null +++ b/logdoctor/modules/crapview/modules/lib.h @@ -0,0 +1,68 @@ +#ifndef LOGDOCTOR__CRAPVIEW__LIB_H +#define LOGDOCTOR__CRAPVIEW__LIB_H + + +#include +#include + +#include + + +#define CRAPVIEW_DATA_TYPEDEFS\ + using stats_dates_t = std::map>>;\ + using stats_warn_items_t = std::vector>>>;\ + using stats_speed_items_t = std::vector>>;\ + using stats_day_items_t = std::unordered_map>;\ + using stats_relat_items_t = std::vector>;\ + using stats_count_items_t = std::multimap;\ + using database_dates_t = std::map; + + +struct RecurrenceData final +{ + QHash protocol; + QHash method; + QHash uri; + QHash user_agent; +}; + +struct TrafficData final +{ + // ( date_str, count ) + std::tuple date; + // { day_name : total_count } // 0:monday, ..., 7:sunday + std::array day{ 0, 0, 0, 0, 0, 0, 0 }; + // { hour : total_count } + std::array hour{ .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0, .0 }; +}; + +struct Perfs final +{ + size_t max{ 0ul }; + size_t total{ 0ul }; + size_t count{ 0ul }; +}; +struct PerformanceData final +{ + // [ max, total, count ] + Perfs time_taken; + // [ max, total, count ] + Perfs bytes_sent; + // [ max, total, count ] + Perfs bytes_recv; +}; + +struct GlobalsData final +{ + RecurrenceData recurs; + TrafficData traf; + PerformanceData perf; + size_t req_count{ 0 }; // total number of requests + + GlobalsData() noexcept = default; + GlobalsData(GlobalsData&&) noexcept = default; + GlobalsData& operator =(GlobalsData&&) noexcept = default; + Q_DISABLE_COPY(GlobalsData) +}; + +#endif // LOGDOCTOR__CRAPVIEW__LIB_H