Support tag history

This commit is contained in:
Alex Gleason
2023-07-25 20:26:49 -05:00
parent 7c8aa88069
commit 1a860adde7
2 changed files with 24 additions and 6 deletions

View File

@@ -12,6 +12,7 @@ const trendingTagsController: AppController = (c) => {
const now = new Date();
const yesterday = new Date(now.getTime() - Time.days(1));
const lastWeek = new Date(now.getTime() - Time.days(7));
const tags = trends.getTrendingTags({
since: yesterday,
@@ -19,14 +20,14 @@ const trendingTagsController: AppController = (c) => {
limit,
});
return c.json(tags.map(({ name, accounts, uses }) => ({
return c.json(tags.map(({ name }) => ({
name,
url: Conf.local(`/tags/${name}`),
history: [{
day: String(Math.floor(yesterday.getTime() / 1000)),
uses: String(uses),
accounts: String(accounts),
}],
history: trends.getTagHistory(name, lastWeek, now).map((history) => ({
day: String(Math.floor(history.day.getTime() / 1000)),
accounts: String(history.accounts),
uses: String(history.uses),
})),
})));
};