diff options
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/api/endpoints/hashtags/trend.ts | 3 | ||||
| -rw-r--r-- | src/server/api/endpoints/meta.ts | 2 | ||||
| -rw-r--r-- | src/server/api/endpoints/stats.ts | 8 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/server/api/endpoints/hashtags/trend.ts b/src/server/api/endpoints/hashtags/trend.ts index 05d571851e..53a3514718 100644 --- a/src/server/api/endpoints/hashtags/trend.ts +++ b/src/server/api/endpoints/hashtags/trend.ts @@ -59,6 +59,7 @@ export default define(meta, async () => { .where(`note.createdAt > :date`, { date: new Date(Date.now() - rangeA) }) .andWhere(`note.tags != '{}'`) .select(['note.tags', 'note.userId']) + .cache(60000) // 1 min .getMany(); if (tagNotes.length === 0) { @@ -108,6 +109,7 @@ export default define(meta, async () => { .where(':tag = ANY(note.tags)', { tag: tag }) .andWhere('note.createdAt < :lt', { lt: new Date(Date.now() - (interval * i)) }) .andWhere('note.createdAt > :gt', { gt: new Date(Date.now() - (interval * (i + 1))) }) + .cache(60000) // 1 min .getRawOne() .then(x => parseInt(x.count, 10)) ))); @@ -119,6 +121,7 @@ export default define(meta, async () => { .select('count(distinct note.userId)') .where(':tag = ANY(note.tags)', { tag: tag }) .andWhere('note.createdAt > :gt', { gt: new Date(Date.now() - (interval * range)) }) + .cache(60000) // 1 min .getRawOne() .then(x => parseInt(x.count, 10)) )); diff --git a/src/server/api/endpoints/meta.ts b/src/server/api/endpoints/meta.ts index 4f418c63c1..d18543f56a 100644 --- a/src/server/api/endpoints/meta.ts +++ b/src/server/api/endpoints/meta.ts @@ -94,7 +94,7 @@ export const meta = { export default define(meta, async (ps, me) => { const instance = await fetchMeta(true); - const emojis = await Emojis.find({ host: null }); + const emojis = await Emojis.find({ where: { host: null }, cache: 3600000 }); // 1 hour const response: any = { maintainerName: instance.maintainerName, diff --git a/src/server/api/endpoints/stats.ts b/src/server/api/endpoints/stats.ts index f85109b4b4..4dca62445f 100644 --- a/src/server/api/endpoints/stats.ts +++ b/src/server/api/endpoints/stats.ts @@ -57,10 +57,10 @@ export default define(meta, async () => { driveUsageLocal, driveUsageRemote ] = await Promise.all([ - Notes.count(), - Notes.count({ userHost: null }), - Users.count(), - Users.count({ host: null }), + Notes.count({ cache: 3600000 }), // 1 hour + Notes.count({ where: { userHost: null }, cache: 3600000 }), + Users.count({ cache: 3600000 }), + Users.count({ where: { host: null }, cache: 3600000 }), federationChart.getChart('hour', 1).then(chart => chart.instance.total[0]), driveChart.getChart('hour', 1).then(chart => chart.local.totalSize[0]), driveChart.getChart('hour', 1).then(chart => chart.remote.totalSize[0]), |