mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
better debounce
This commit is contained in:
@@ -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> }) {
|
private createPgConnection(options?: { max?: number; connection?: Record<string, string> }) {
|
||||||
const { database } = this.configRepository.getEnv();
|
const { database } = this.configRepository.getEnv();
|
||||||
const pgConfig = asPostgresConnectionConfig(database.config);
|
const pgConfig = asPostgresConnectionConfig(database.config);
|
||||||
|
|||||||
@@ -506,7 +506,6 @@ describe(NotificationService.name, () => {
|
|||||||
|
|
||||||
it('should add new recipients for new images if job is already queued', async () => {
|
it('should add new recipients for new images if job is already queued', async () => {
|
||||||
await sut.onAlbumUpdate({ id: '1', recipientId: '2' } as INotifyAlbumUpdateJob);
|
await sut.onAlbumUpdate({ id: '1', recipientId: '2' } as INotifyAlbumUpdateJob);
|
||||||
expect(mocks.job.removeJob).toHaveBeenCalledWith(JobName.NotifyAlbumUpdate, '1/2');
|
|
||||||
expect(mocks.job.queue).toHaveBeenCalledWith({
|
expect(mocks.job.queue).toHaveBeenCalledWith({
|
||||||
name: JobName.NotifyAlbumUpdate,
|
name: JobName.NotifyAlbumUpdate,
|
||||||
data: {
|
data: {
|
||||||
|
|||||||
@@ -218,7 +218,6 @@ export class NotificationService extends BaseService {
|
|||||||
|
|
||||||
@OnEvent({ name: 'AlbumUpdate' })
|
@OnEvent({ name: 'AlbumUpdate' })
|
||||||
async onAlbumUpdate({ id, recipientId }: ArgOf<'AlbumUpdate'>) {
|
async onAlbumUpdate({ id, recipientId }: ArgOf<'AlbumUpdate'>) {
|
||||||
await this.jobRepository.removeJob(JobName.NotifyAlbumUpdate, `${id}/${recipientId}`);
|
|
||||||
await this.jobRepository.queue({
|
await this.jobRepository.queue({
|
||||||
name: JobName.NotifyAlbumUpdate,
|
name: JobName.NotifyAlbumUpdate,
|
||||||
data: { id, recipientId, delay: NotificationService.albumUpdateEmailDelayMs },
|
data: { id, recipientId, delay: NotificationService.albumUpdateEmailDelayMs },
|
||||||
|
|||||||
@@ -435,7 +435,8 @@ export class WriteBuffer {
|
|||||||
${runAfter}::timestamptz[]
|
${runAfter}::timestamptz[]
|
||||||
)
|
)
|
||||||
ON CONFLICT ("dedupKey") WHERE "dedupKey" IS NOT NULL
|
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}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ export const newJobRepositoryMock = (): Mocked<RepositoryInterface<JobRepository
|
|||||||
getJobCounts: vitest.fn(),
|
getJobCounts: vitest.fn(),
|
||||||
clear: vitest.fn(),
|
clear: vitest.fn(),
|
||||||
waitForQueueCompletion: vitest.fn(),
|
waitForQueueCompletion: vitest.fn(),
|
||||||
removeJob: vitest.fn(),
|
|
||||||
onShutdown: vitest.fn(),
|
onShutdown: vitest.fn(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user