2023-12-30 00:15:03 +08:00
|
|
|
#ifndef __DATABASE_H__
|
|
|
|
#define __DATABASE_H__
|
|
|
|
|
2024-07-10 22:37:40 +08:00
|
|
|
#include "HomeBox.h"
|
2023-12-30 01:19:36 +08:00
|
|
|
#include "Singleton.h"
|
2024-01-03 22:44:36 +08:00
|
|
|
#include "Task.h"
|
2023-12-30 00:15:03 +08:00
|
|
|
#include <string>
|
|
|
|
|
2024-07-30 22:17:55 +08:00
|
|
|
class VisitAnalysis {
|
|
|
|
public:
|
|
|
|
std::string url;
|
|
|
|
int pageViewCount = 0;
|
|
|
|
int uniqueVisitorCount = 0;
|
|
|
|
};
|
|
|
|
|
2023-12-30 01:19:36 +08:00
|
|
|
struct sqlite3;
|
|
|
|
|
2023-12-30 00:15:03 +08:00
|
|
|
class Database {
|
2023-12-30 01:19:36 +08:00
|
|
|
friend class Amass::Singleton<Database>;
|
|
|
|
|
2023-12-30 00:15:03 +08:00
|
|
|
public:
|
2023-12-30 01:19:36 +08:00
|
|
|
~Database();
|
2023-12-30 00:15:03 +08:00
|
|
|
bool open(const std::string &path);
|
2024-01-03 22:44:36 +08:00
|
|
|
Tasks tasks();
|
2024-01-04 23:32:07 +08:00
|
|
|
bool addTask(uint64_t createTime, const std::string &content, const std::string &comment = "", int parentId = -1,
|
2024-01-03 22:44:36 +08:00
|
|
|
bool finished = false);
|
|
|
|
bool removeTask(int id);
|
2023-12-30 01:19:36 +08:00
|
|
|
void setTaskFinished(int id, bool finished, uint64_t finishedTime);
|
|
|
|
|
2024-07-31 22:28:05 +08:00
|
|
|
void updateVisitCount(const std::string &url, const std::string &visitorUuid, const std::string &userAgent,
|
|
|
|
int64_t time);
|
2024-07-30 23:17:42 +08:00
|
|
|
void clearVisitRecord();
|
2024-07-30 22:17:55 +08:00
|
|
|
VisitAnalysis visitAnalysisData(const std::string &url);
|
2024-07-30 23:17:42 +08:00
|
|
|
VisitAnalysis siteVisitAnalysisData();
|
2024-08-05 23:01:19 +08:00
|
|
|
std::list<VisitAnalysis> mostViewedUrls(int size);
|
2024-07-29 00:46:11 +08:00
|
|
|
|
2024-07-10 22:37:40 +08:00
|
|
|
HomeBox::Items homeBoxItems();
|
|
|
|
bool addHomeBoxItem(const std::string &name, const std::string &location, int cost);
|
|
|
|
|
2023-12-30 01:19:36 +08:00
|
|
|
protected:
|
|
|
|
void initialize();
|
|
|
|
|
|
|
|
private:
|
|
|
|
sqlite3 *m_sqlite3 = nullptr;
|
2023-12-30 00:15:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __DATABASE_H__
|