#ifndef __DATABASE_H__ #define __DATABASE_H__ #include "HomeBox.h" #include "Singleton.h" #include "Task.h" #include namespace Wt { namespace Dbo { class SqlConnectionPool; } } // namespace Wt class VisitAnalysis { public: std::string url; int pageViewCount = 0; int uniqueVisitorCount = 0; int lastViewTime = 0; }; struct sqlite3; class Session; class Database { friend class Amass::Singleton; public: ~Database(); std::unique_ptr session(); bool open(const std::string &path); void updateVisitCount(const std::string &url, const std::string &visitorUuid, const std::string &userAgent, int64_t time); void clearVisitRecord(); VisitAnalysis visitAnalysisData(const std::string &url); VisitAnalysis siteVisitAnalysisData(); std::list mostViewedUrls(int size); std::list latestViewedUrls(int size); protected: void initialize(); private: std::unique_ptr m_sqlConnectionPool; sqlite3 *m_sqlite3 = nullptr; }; #endif // __DATABASE_H__