mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor(server): jobs and processors (#1787)
* refactor: jobs and processors * refactor: storage migration processor * fix: tests * fix: code warning * chore: ignore coverage from infra * fix: sync move asset logic between job core and asset core * refactor: move error handling inside of catch * refactor(server): job core into dedicated service calls * refactor: smart info * fix: tests * chore: smart info tests * refactor: use asset repository * refactor: thumbnail processor * chore: coverage reqs
This commit is contained in:
parent
71d8567f18
commit
6c7679714b
108 changed files with 1645 additions and 1072 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { AssetEntity } from '@app/infra';
|
||||
import { AssetEntity } from '@app/infra/db/entities';
|
||||
import { AssetResponseDto } from '@app/domain';
|
||||
import fs from 'fs';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { LogLevel } from '@nestjs/common';
|
|||
|
||||
export * from './time-utils';
|
||||
export * from './asset-utils';
|
||||
export * from './user-utils';
|
||||
|
||||
export function getLogLevels() {
|
||||
const LOG_LEVELS: LogLevel[] = ['verbose', 'debug', 'log', 'warn', 'error'];
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
// create unit test for user utils
|
||||
|
||||
import { UserEntity } from '@app/infra';
|
||||
import { userUtils } from './user-utils';
|
||||
|
||||
describe('User Utilities', () => {
|
||||
describe('checkIsReadyForDeletion', () => {
|
||||
it('check that user is not ready to be deleted', () => {
|
||||
const result = userUtils.isReadyForDeletion({ deletedAt: new Date() } as UserEntity);
|
||||
expect(result).toBeFalsy();
|
||||
});
|
||||
|
||||
it('check that user is ready to be deleted', () => {
|
||||
const aWeekAgo = new Date(new Date().getTime() - 8 * 86400000);
|
||||
const result = userUtils.isReadyForDeletion({ deletedAt: aWeekAgo } as UserEntity);
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import { UserEntity } from '@app/infra';
|
||||
|
||||
function createUserUtils() {
|
||||
const isReadyForDeletion = (user: UserEntity): boolean => {
|
||||
if (user.deletedAt == null) return false;
|
||||
const millisecondsInDay = 86400000;
|
||||
// get this number (7 days) from some configuration perhaps ?
|
||||
const millisecondsDeleteWait = millisecondsInDay * 7;
|
||||
|
||||
const millisecondsSinceDelete = new Date().getTime() - (Date.parse(user.deletedAt.toString()) ?? 0);
|
||||
return millisecondsSinceDelete >= millisecondsDeleteWait;
|
||||
};
|
||||
return { isReadyForDeletion };
|
||||
}
|
||||
|
||||
export const userUtils = createUserUtils();
|
||||
Loading…
Add table
Add a link
Reference in a new issue