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:
Jason Rasmussen 2023-02-25 09:12:03 -05:00 committed by GitHub
parent 71d8567f18
commit 6c7679714b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
108 changed files with 1645 additions and 1072 deletions

View file

@ -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';

View file

@ -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'];

View file

@ -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();
});
});
});

View file

@ -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();