add size filter.
All checks were successful
Deploy / PullDocker (push) Successful in 6s
Deploy / Build (push) Successful in 54s

This commit is contained in:
luocai 2024-08-07 15:47:30 +08:00
parent 303f89d345
commit 6f0b50218b

View File

@ -213,14 +213,15 @@ std::list<VisitAnalysis> Database::mostViewedUrls(int size) {
pv.url = reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)); pv.url = reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0));
if (std::find(urlFilter.cbegin(), urlFilter.cend(), pv.url) != urlFilter.cend()) continue; if (std::find(urlFilter.cbegin(), urlFilter.cend(), pv.url) != urlFilter.cend()) continue;
pv.pageViewCount = sqlite3_column_int(stmt, 1); pv.pageViewCount = sqlite3_column_int(stmt, 1);
ret.push_back(pv); if (ret.size() < size) {
ret.push_back(pv);
}
} }
if (rc != SQLITE_DONE) { if (rc != SQLITE_DONE) {
LOG(error) << "Failed to execute statement: " << sqlite3_errmsg(m_sqlite3); LOG(error) << "Failed to execute statement: " << sqlite3_errmsg(m_sqlite3);
} }
sqlite3_finalize(stmt); sqlite3_finalize(stmt);
return ret; return ret;
} }
@ -251,7 +252,9 @@ std::list<VisitAnalysis> Database::latestViewedUrls(int size) {
visit.url = reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0)); visit.url = reinterpret_cast<const char *>(sqlite3_column_text(stmt, 0));
if (std::find(urlFilter.cbegin(), urlFilter.cend(), visit.url) != urlFilter.cend()) continue; if (std::find(urlFilter.cbegin(), urlFilter.cend(), visit.url) != urlFilter.cend()) continue;
visit.lastViewTime = sqlite3_column_int64(stmt, 1); visit.lastViewTime = sqlite3_column_int64(stmt, 1);
ret.push_back(visit); if (ret.size() < size) {
ret.push_back(visit);
}
} }
return ret; return ret;
} }