better debounce

This commit is contained in:
mertalev
2026-02-14 02:47:39 -05:00
parent 8bfacda3da
commit 947f00ac9d
5 changed files with 2 additions and 14 deletions

View File

@@ -394,16 +394,6 @@ export class JobRepository {
}
}
/** @deprecated */
// todo: remove this when asset notifications no longer need it.
removeJob(name: JobName, dedupKey: string) {
return this.db
.deleteFrom(getTable(this.db, this.getQueueName(name)))
.where('dedupKey', '=', dedupKey)
.where('status', '=', JobQueueStatus.Pending)
.execute();
}
private createPgConnection(options?: { max?: number; connection?: Record<string, string> }) {
const { database } = this.configRepository.getEnv();
const pgConfig = asPostgresConnectionConfig(database.config);

View File

@@ -506,7 +506,6 @@ describe(NotificationService.name, () => {
it('should add new recipients for new images if job is already queued', async () => {
await sut.onAlbumUpdate({ id: '1', recipientId: '2' } as INotifyAlbumUpdateJob);
expect(mocks.job.removeJob).toHaveBeenCalledWith(JobName.NotifyAlbumUpdate, '1/2');
expect(mocks.job.queue).toHaveBeenCalledWith({
name: JobName.NotifyAlbumUpdate,
data: {

View File

@@ -218,7 +218,6 @@ export class NotificationService extends BaseService {
@OnEvent({ name: 'AlbumUpdate' })
async onAlbumUpdate({ id, recipientId }: ArgOf<'AlbumUpdate'>) {
await this.jobRepository.removeJob(JobName.NotifyAlbumUpdate, `${id}/${recipientId}`);
await this.jobRepository.queue({
name: JobName.NotifyAlbumUpdate,
data: { id, recipientId, delay: NotificationService.albumUpdateEmailDelayMs },

View File

@@ -435,7 +435,8 @@ export class WriteBuffer {
${runAfter}::timestamptz[]
)
ON CONFLICT ("dedupKey") WHERE "dedupKey" IS NOT NULL
DO NOTHING
DO UPDATE SET "runAfter" = EXCLUDED."runAfter", data = EXCLUDED.data
WHERE ${this.pgPool(tableName)}.status = ${JobQueueStatus.Pending}
`;
}
}

View File

@@ -19,7 +19,6 @@ export const newJobRepositoryMock = (): Mocked<RepositoryInterface<JobRepository
getJobCounts: vitest.fn(),
clear: vitest.fn(),
waitForQueueCompletion: vitest.fn(),
removeJob: vitest.fn(),
onShutdown: vitest.fn(),
};
};