同じノートを何回リノートしても一回として数えるように (#6086)
* 同じノートを何回リノートしても一回として数えるように * Update count-same-renotes.ts Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
parent
241769d6fc
commit
f6c376f20d
3 changed files with 21 additions and 2 deletions
15
src/services/count-same-renotes.ts
Normal file
15
src/services/count-same-renotes.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { Notes } from '../models';
|
||||
|
||||
export default async function(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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue