Trends: add limit param, fix order
This commit is contained in:
parent
1a860adde7
commit
ad48e4a787
|
@ -54,16 +54,17 @@ class TrendsDB {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
getTagHistory(tag: string, since: Date, until: Date) {
|
getTagHistory(tag: string, since: Date, until: Date, limit = 7) {
|
||||||
return this.#db.query<string[]>(
|
return this.#db.query<string[]>(
|
||||||
`
|
`
|
||||||
SELECT inserted_at, COUNT(DISTINCT pubkey8), COUNT(*)
|
SELECT inserted_at, COUNT(DISTINCT pubkey8), COUNT(*)
|
||||||
FROM tag_usages
|
FROM tag_usages
|
||||||
WHERE tag = ? AND inserted_at >= ? AND inserted_at < ?
|
WHERE tag = ? AND inserted_at >= ? AND inserted_at < ?
|
||||||
GROUP BY date(inserted_at)
|
GROUP BY date(inserted_at)
|
||||||
ORDER BY date(inserted_at);
|
ORDER BY date(inserted_at) DESC
|
||||||
|
LIMIT ?;
|
||||||
`,
|
`,
|
||||||
[tag, since, until],
|
[tag, since, until, limit],
|
||||||
).map((row) => ({
|
).map((row) => ({
|
||||||
day: new Date(row[0]),
|
day: new Date(row[0]),
|
||||||
accounts: Number(row[1]),
|
accounts: Number(row[1]),
|
||||||
|
|
Loading…
Reference in New Issue