review suggestions, vector migrations on bootstrap
This commit is contained in:
parent
1a25f3fef7
commit
4ec6d107b1
7 changed files with 19 additions and 21 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
import { SearchExploreItem } from '@app/domain';
|
||||||
import { AssetEntity, AssetJobStatusEntity, AssetType, ExifEntity } from '@app/infra/entities';
|
import { AssetEntity, AssetJobStatusEntity, AssetType, ExifEntity } from '@app/infra/entities';
|
||||||
import { FindOptionsRelations } from 'typeorm';
|
import { FindOptionsRelations } from 'typeorm';
|
||||||
import { Paginated, PaginationOptions } from '../domain.util';
|
import { Paginated, PaginationOptions } from '../domain.util';
|
||||||
import { SearchExploreItem } from '../repositories';
|
|
||||||
|
|
||||||
export type AssetStats = Record<AssetType, number>;
|
export type AssetStats = Record<AssetType, number>;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { Embedding, EmbeddingSearch } from '@app/domain';
|
||||||
import { AssetEntity, SmartInfoEntity } from '@app/infra/entities';
|
import { AssetEntity, SmartInfoEntity } from '@app/infra/entities';
|
||||||
import { Embedding, EmbeddingSearch } from '../repositories';
|
|
||||||
|
|
||||||
export const ISmartInfoRepository = 'ISmartInfoRepository';
|
export const ISmartInfoRepository = 'ISmartInfoRepository';
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import { SearchResponseDto } from './response-dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SearchService {
|
export class SearchService {
|
||||||
private timer: NodeJS.Timeout | null = null;
|
|
||||||
private logger = new Logger(SearchService.name);
|
private logger = new Logger(SearchService.name);
|
||||||
private configCore: SystemConfigCore;
|
private configCore: SystemConfigCore;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { envName, getLogLevels, isDev, serverVersion } from '@app/domain';
|
import { envName, getLogLevels, isDev, serverVersion } from '@app/domain';
|
||||||
import { RedisIoAdapter } from '@app/infra';
|
import { RedisIoAdapter, runVectorMigrations } from '@app/infra';
|
||||||
import { Logger } from '@nestjs/common';
|
import { Logger } from '@nestjs/common';
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||||
|
@ -29,6 +29,8 @@ export async function bootstrap() {
|
||||||
app.useStaticAssets('www');
|
app.useStaticAssets('www');
|
||||||
app.use(indexFallback(excludePaths));
|
app.use(indexFallback(excludePaths));
|
||||||
|
|
||||||
|
await runVectorMigrations();
|
||||||
|
|
||||||
const server = await app.listen(port);
|
const server = await app.listen(port);
|
||||||
server.requestTimeout = 30 * 60 * 1000;
|
server.requestTimeout = 30 * 60 * 1000;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,13 @@ export const databaseConfigVector: PostgresConnectionOptions = {
|
||||||
migrations: [__dirname + '/migrations/vector/*.{js,ts}'],
|
migrations: [__dirname + '/migrations/vector/*.{js,ts}'],
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function initDataSource(): Promise<DataSource> {
|
// this export is used by TypeORM commands in package.json#scripts
|
||||||
const dataSource = await new DataSource(databaseConfig).initialize();
|
export let dataSource = new DataSource(databaseConfig);
|
||||||
|
|
||||||
|
export async function runVectorMigrations(): Promise<void> {
|
||||||
|
if (!dataSource.isInitialized) {
|
||||||
|
dataSource = await dataSource.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
const hasVectorExtension = (await dataSource.query(
|
const hasVectorExtension = (await dataSource.query(
|
||||||
`SELECT * FROM pg_available_extensions WHERE name = 'vectors'`,
|
`SELECT * FROM pg_available_extensions WHERE name = 'vectors'`,
|
||||||
|
@ -44,12 +49,4 @@ export async function initDataSource(): Promise<DataSource> {
|
||||||
|
|
||||||
await dataSourceVector.destroy();
|
await dataSourceVector.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this export is used by TypeORM commands in package.json#scripts
|
|
||||||
export let dataSource: DataSource;
|
|
||||||
(async () => {
|
|
||||||
dataSource = await initDataSource();
|
|
||||||
})();
|
|
||||||
|
|
|
@ -20,9 +20,9 @@ import { ExifEntity } from './exif.entity';
|
||||||
import { LibraryEntity } from './library.entity';
|
import { LibraryEntity } from './library.entity';
|
||||||
import { SharedLinkEntity } from './shared-link.entity';
|
import { SharedLinkEntity } from './shared-link.entity';
|
||||||
import { SmartInfoEntity } from './smart-info.entity';
|
import { SmartInfoEntity } from './smart-info.entity';
|
||||||
|
import { SmartSearchEntity } from './smart-search.entity';
|
||||||
import { TagEntity } from './tag.entity';
|
import { TagEntity } from './tag.entity';
|
||||||
import { UserEntity } from './user.entity';
|
import { UserEntity } from './user.entity';
|
||||||
import { SmartSearchEntity } from '.';
|
|
||||||
|
|
||||||
export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';
|
export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue