Older/Server/Database/Database.h
luocai 0b6ccfd841
All checks were successful
Deploy / PullDocker (push) Successful in 3s
Deploy / Build (push) Successful in 55s
add latest viewed url query.
2024-08-06 09:48:25 +08:00

49 lines
1.3 KiB
C++

#ifndef __DATABASE_H__
#define __DATABASE_H__
#include "HomeBox.h"
#include "Singleton.h"
#include "Task.h"
#include <string>
class VisitAnalysis {
public:
std::string url;
int pageViewCount = 0;
int uniqueVisitorCount = 0;
int lastViewTime = 0;
};
struct sqlite3;
class Database {
friend class Amass::Singleton<Database>;
public:
~Database();
bool open(const std::string &path);
Tasks tasks();
bool addTask(uint64_t createTime, const std::string &content, const std::string &comment = "", int parentId = -1,
bool finished = false);
bool removeTask(int id);
void setTaskFinished(int id, bool finished, uint64_t finishedTime);
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);
HomeBox::Items homeBoxItems();
bool addHomeBoxItem(const std::string &name, const std::string &location, int cost);
protected:
void initialize();
private:
sqlite3 *m_sqlite3 = nullptr;
};
#endif // __DATABASE_H__