Older/Database/Database.h
amass 059d6d3879
Some checks failed
Deploy / Build (push) Failing after 3m33s
use wt dbo.
2024-11-26 22:58:54 +08:00

49 lines
1.1 KiB
C++

#ifndef __DATABASE_H__
#define __DATABASE_H__
#include "HomeBox.h"
#include "Singleton.h"
#include "Task.h"
#include <string>
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<Database>;
public:
~Database();
std::unique_ptr<Session> 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<VisitAnalysis> mostViewedUrls(int size);
std::list<VisitAnalysis> latestViewedUrls(int size);
protected:
void initialize();
private:
std::unique_ptr<Wt::Dbo::SqlConnectionPool> m_sqlConnectionPool;
sqlite3 *m_sqlite3 = nullptr;
};
#endif // __DATABASE_H__