34 lines
883 B
C++
34 lines
883 B
C++
#ifndef __DATABASE_H__
|
|
#define __DATABASE_H__
|
|
|
|
#include "Base/DataStructure.h"
|
|
#include <list>
|
|
#include <string>
|
|
|
|
typedef struct sqlite3 sqlite3;
|
|
|
|
namespace Older {
|
|
class Database {
|
|
public:
|
|
bool open(const std::string &path);
|
|
void upsertVisitRecord(const std::string &url, const std::string &visitorUuid, const std::string &userAgent,
|
|
int64_t viewTime);
|
|
VisitorStats visitorStats(const std::string &url);
|
|
|
|
std::list<VisitorStats> mostViewedUrls(int n);
|
|
std::list<VisitorStats> latestViewedUrls(int n);
|
|
SiteStats siteStats();
|
|
void createUser(const Account &account);
|
|
Account user(const std::string &identifier)const;
|
|
Account user(int64_t id)const;
|
|
|
|
protected:
|
|
void createVisitAnalysisTable();
|
|
void createUsersTable();
|
|
void initialize();
|
|
|
|
private:
|
|
sqlite3 *m_sqlite = nullptr;
|
|
};}
|
|
|
|
#endif // __DATABASE_H__
|