summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-02-26 07:56:32 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-02-26 07:56:32 +0900
commit7121bdef6b232294acda25b169be1e008a8812b6 (patch)
tree9b4ca00b2fdef9ab2c385382ec8e023ef5e69fd1 /src/misc
parent同じノートを何回リノートしても一回として数えるよう... (diff)
downloadmisskey-7121bdef6b232294acda25b169be1e008a8812b6.tar.gz
misskey-7121bdef6b232294acda25b169be1e008a8812b6.tar.bz2
misskey-7121bdef6b232294acda25b169be1e008a8812b6.zip
Refactor
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/count-same-renotes.ts15
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();
+}