implement clippedCountDelta in updateNoteQueue
This commit is contained in:
parent
101f8f6df5
commit
dceb6dffc9
2 changed files with 7 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import { bindThis } from '@/decorators.js';
|
|||
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { CollapsedQueueService } from '@/core/CollapsedQueueService.js';
|
||||
import type { MiLocalUser } from '@/models/User.js';
|
||||
import { TimeService } from '@/global/TimeService.js';
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ export class ClipService {
|
|||
private roleService: RoleService,
|
||||
private idService: IdService,
|
||||
private readonly timeService: TimeService,
|
||||
private readonly collapsedQueueService: CollapsedQueueService,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +132,7 @@ export class ClipService {
|
|||
lastClippedAt: this.timeService.date,
|
||||
});
|
||||
|
||||
this.notesRepository.increment({ id: noteId }, 'clippedCount', 1);
|
||||
this.collapsedQueueService.updateNoteQueue.enqueue(noteId, { clippedCountDelta: 1 });
|
||||
}
|
||||
|
||||
@bindThis
|
||||
|
|
@ -155,6 +157,6 @@ export class ClipService {
|
|||
clipId: clip.id,
|
||||
});
|
||||
|
||||
this.notesRepository.decrement({ id: noteId }, 'clippedCount', 1);
|
||||
this.collapsedQueueService.updateNoteQueue.enqueue(noteId, { clippedCountDelta: -1 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export type UpdateUserJob = {
|
|||
export type UpdateNoteJob = {
|
||||
repliesCountDelta?: number;
|
||||
renoteCountDelta?: number;
|
||||
clippedCountDelta?: number;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -107,10 +108,12 @@ export class CollapsedQueueService implements OnApplicationShutdown {
|
|||
(oldJob, newJob) => ({
|
||||
repliesCountDelta: (oldJob.repliesCountDelta ?? 0) + (newJob.repliesCountDelta ?? 0),
|
||||
renoteCountDelta: (oldJob.renoteCountDelta ?? 0) + (newJob.renoteCountDelta ?? 0),
|
||||
clippedCountDelta: (oldJob.clippedCountDelta ?? 0) + (newJob.clippedCountDelta ?? 0),
|
||||
}),
|
||||
(id, job) => this.notesRepository.update({ id }, {
|
||||
repliesCount: job.repliesCountDelta ? () => `"repliesCount" + ${job.repliesCountDelta}` : undefined,
|
||||
renoteCount: job.renoteCountDelta ? () => `"renoteCount" + ${job.renoteCountDelta}` : undefined,
|
||||
clippedCount: job.clippedCountDelta ? () => `"clippedCount" + ${job.clippedCountDelta}` : undefined,
|
||||
}),
|
||||
{
|
||||
onError: this.onQueueError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue