Skip to content

Commit

Permalink
/_info_card_ のユーザー数・ノート数のクエリをキャッシュする (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
riku6460 authored Mar 7, 2024
1 parent 9728608 commit c6376a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/backend/src/server/web/ClientServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,17 @@ export class ClientServerService {

reply.removeHeader('X-Frame-Options');

const [originalUsersCount, originalNotesCount] = await Promise.all([
this.usersRepository.count({ where: { host: IsNull() }, cache: 1000 * 60 * 60 * 6 }), // 6 hours
this.notesRepository.count({ where: { userHost: IsNull() }, cache: 1000 * 60 * 60 * 6 }), // 6 hours
]);

return await reply.view('info-card', {
version: this.config.version,
host: this.config.host,
meta: meta,
originalUsersCount: await this.usersRepository.countBy({ host: IsNull() }),
originalNotesCount: await this.notesRepository.countBy({ userHost: IsNull() }),
originalUsersCount,
originalNotesCount,
});
});

Expand Down

0 comments on commit c6376a3

Please sign in to comment.