diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-26 07:56:32 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2020-02-26 07:56:32 +0900 |
| commit | 7121bdef6b232294acda25b169be1e008a8812b6 (patch) | |
| tree | 9b4ca00b2fdef9ab2c385382ec8e023ef5e69fd1 /src/misc | |
| parent | 同じノートを何回リノートしても一回として数えるよう... (diff) | |
| download | misskey-7121bdef6b232294acda25b169be1e008a8812b6.tar.gz misskey-7121bdef6b232294acda25b169be1e008a8812b6.tar.bz2 misskey-7121bdef6b232294acda25b169be1e008a8812b6.zip | |
Refactor
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/count-same-renotes.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/misc/count-same-renotes.ts b/src/misc/count-same-renotes.ts new file mode 100644 index 0000000000..0233bdf88e --- /dev/null +++ b/src/misc/count-same-renotes.ts @@ -0,0 +1,15 @@ +import { Notes } from '../models'; + +export async function countSameRenotes(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise<number> { + // 指定したユーザーの指定したノートのリノートがいくつあるか数える + const query = Notes.createQueryBuilder('note') + .where('note.userId = :userId', { userId }) + .andWhere('note.renoteId = :renoteId', { renoteId }) + + // 指定した投稿を除く + if (excludeNoteId) { + query.andWhere('note.id != :excludeNoteId', { excludeNoteId }) + } + + return await query.getCount(); +} |