1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-28 09:33:27 +02:00

chore(server): remove asset search endpoint (#5094)

* chore(server): remove unused search endpoint

* chore: open api
This commit is contained in:
Jason Rasmussen 2023-11-16 23:24:31 -05:00 committed by GitHub
parent ed68c49c16
commit c7b3039a1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 3 additions and 308 deletions

View File

@ -2794,19 +2794,6 @@ export interface SearchAlbumResponseDto {
*/
'total': number;
}
/**
*
* @export
* @interface SearchAssetDto
*/
export interface SearchAssetDto {
/**
*
* @type {string}
* @memberof SearchAssetDto
*/
'searchTerm': string;
}
/**
*
* @export
@ -7792,50 +7779,6 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
options: localVarRequestOptions,
};
},
/**
*
* @param {SearchAssetDto} searchAssetDto
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
searchAsset: async (searchAssetDto: SearchAssetDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'searchAssetDto' is not null or undefined
assertParamExists('searchAsset', 'searchAssetDto', searchAssetDto)
const localVarPath = `/asset/search`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication cookie required
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration)
// authentication bearer required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(searchAssetDto, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {string} [id]
@ -8698,16 +8641,6 @@ export const AssetApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.runAssetJobs(assetJobsDto, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {SearchAssetDto} searchAssetDto
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async searchAsset(searchAssetDto: SearchAssetDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AssetResponseDto>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.searchAsset(searchAssetDto, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {string} [id]
@ -9047,15 +8980,6 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
runAssetJobs(requestParameters: AssetApiRunAssetJobsRequest, options?: AxiosRequestConfig): AxiosPromise<void> {
return localVarFp.runAssetJobs(requestParameters.assetJobsDto, options).then((request) => request(axios, basePath));
},
/**
*
* @param {AssetApiSearchAssetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
searchAsset(requestParameters: AssetApiSearchAssetRequest, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
return localVarFp.searchAsset(requestParameters.searchAssetDto, options).then((request) => request(axios, basePath));
},
/**
*
* @param {AssetApiSearchAssetsRequest} requestParameters Request parameters.
@ -9645,20 +9569,6 @@ export interface AssetApiRunAssetJobsRequest {
readonly assetJobsDto: AssetJobsDto
}
/**
* Request parameters for searchAsset operation in AssetApi.
* @export
* @interface AssetApiSearchAssetRequest
*/
export interface AssetApiSearchAssetRequest {
/**
*
* @type {SearchAssetDto}
* @memberof AssetApiSearchAsset
*/
readonly searchAssetDto: SearchAssetDto
}
/**
* Request parameters for searchAssets operation in AssetApi.
* @export
@ -10415,17 +10325,6 @@ export class AssetApi extends BaseAPI {
return AssetApiFp(this.configuration).runAssetJobs(requestParameters.assetJobsDto, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {AssetApiSearchAssetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AssetApi
*/
public searchAsset(requestParameters: AssetApiSearchAssetRequest, options?: AxiosRequestConfig) {
return AssetApiFp(this.configuration).searchAsset(requestParameters.searchAssetDto, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {AssetApiSearchAssetsRequest} requestParameters Request parameters.

View File

@ -109,7 +109,6 @@ doc/RecognitionConfig.md
doc/ScanLibraryDto.md
doc/SearchAlbumResponseDto.md
doc/SearchApi.md
doc/SearchAssetDto.md
doc/SearchAssetResponseDto.md
doc/SearchExploreItem.md
doc/SearchExploreResponseDto.md
@ -293,7 +292,6 @@ lib/model/reaction_type.dart
lib/model/recognition_config.dart
lib/model/scan_library_dto.dart
lib/model/search_album_response_dto.dart
lib/model/search_asset_dto.dart
lib/model/search_asset_response_dto.dart
lib/model/search_explore_item.dart
lib/model/search_explore_response_dto.dart
@ -458,7 +456,6 @@ test/recognition_config_test.dart
test/scan_library_dto_test.dart
test/search_album_response_dto_test.dart
test/search_api_test.dart
test/search_asset_dto_test.dart
test/search_asset_response_dto_test.dart
test/search_explore_item_test.dart
test/search_explore_response_dto_test.dart

BIN
mobile/openapi/README.md generated

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1763,51 +1763,6 @@
]
}
},
"/asset/search": {
"post": {
"operationId": "searchAsset",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SearchAssetDto"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/AssetResponseDto"
},
"type": "array"
}
}
},
"description": ""
}
},
"security": [
{
"bearer": []
},
{
"cookie": []
},
{
"api_key": []
}
],
"tags": [
"Asset"
]
}
},
"/asset/search-terms": {
"get": {
"operationId": "getAssetSearchTerms",
@ -8346,17 +8301,6 @@
],
"type": "object"
},
"SearchAssetDto": {
"properties": {
"searchTerm": {
"type": "string"
}
},
"required": [
"searchTerm"
],
"type": "object"
},
"SearchAssetResponseDto": {
"properties": {
"count": {

View File

@ -27,7 +27,6 @@ import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto';
import { CreateAssetDto, ImportAssetDto } from './dto/create-asset.dto';
import { DeviceIdDto } from './dto/device-id.dto';
import { GetAssetThumbnailDto } from './dto/get-asset-thumbnail.dto';
import { SearchAssetDto } from './dto/search-asset.dto';
import { ServeFileDto } from './dto/serve-file.dto';
import { AssetBulkUploadCheckResponseDto } from './response-dto/asset-check-response.dto';
import { AssetFileUploadResponseDto } from './response-dto/asset-file-upload-response.dto';
@ -144,15 +143,6 @@ export class AssetController {
return this.assetService.getAssetSearchTerm(authUser);
}
@Post('/search')
@HttpCode(HttpStatus.OK)
searchAsset(
@AuthUser() authUser: AuthUserDto,
@Body(ValidationPipe) dto: SearchAssetDto,
): Promise<AssetResponseDto[]> {
return this.assetService.searchAsset(authUser, dto);
}
/**
* Get all AssetEntity belong to the user
*/

View File

@ -13,7 +13,7 @@ import {
newStorageRepositoryMock,
} from '@test';
import { when } from 'jest-when';
import { QueryFailedError, Repository } from 'typeorm';
import { QueryFailedError } from 'typeorm';
import { IAssetRepository } from './asset-repository';
import { AssetService } from './asset.service';
import { CreateAssetDto } from './dto/create-asset.dto';
@ -85,7 +85,6 @@ const _getAssets = () => {
describe('AssetService', () => {
let sut: AssetService;
let a: Repository<AssetEntity>; // TO BE DELETED AFTER FINISHED REFACTORING
let accessMock: IAccessRepositoryMock;
let assetRepositoryMock: jest.Mocked<IAssetRepository>;
let cryptoMock: jest.Mocked<ICryptoRepository>;
@ -115,7 +114,7 @@ describe('AssetService', () => {
storageMock = newStorageRepositoryMock();
libraryMock = newLibraryRepositoryMock();
sut = new AssetService(accessMock, assetRepositoryMock, a, cryptoMock, jobMock, libraryMock, storageMock);
sut = new AssetService(accessMock, assetRepositoryMock, cryptoMock, jobMock, libraryMock, storageMock);
when(assetRepositoryMock.get)
.calledWith(assetStub.livePhotoStillAsset.id)

View File

@ -24,12 +24,11 @@ import {
Logger,
NotFoundException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Response as Res, Response } from 'express';
import { constants } from 'fs';
import fs from 'fs/promises';
import path from 'path';
import { QueryFailedError, Repository } from 'typeorm';
import { QueryFailedError } from 'typeorm';
import { IAssetRepository } from './asset-repository';
import { AssetCore } from './asset.core';
import { AssetBulkUploadCheckDto } from './dto/asset-check.dto';
@ -37,7 +36,6 @@ import { AssetSearchDto } from './dto/asset-search.dto';
import { CheckExistingAssetsDto } from './dto/check-existing-assets.dto';
import { CreateAssetDto, ImportAssetDto } from './dto/create-asset.dto';
import { GetAssetThumbnailDto, GetAssetThumbnailFormatEnum } from './dto/get-asset-thumbnail.dto';
import { SearchAssetDto } from './dto/search-asset.dto';
import { SearchPropertiesDto } from './dto/search-properties.dto';
import { ServeFileDto } from './dto/serve-file.dto';
import {
@ -62,7 +60,6 @@ export class AssetService {
constructor(
@Inject(IAccessRepository) accessRepository: IAccessRepository,
@Inject(IAssetRepository) private _assetRepository: IAssetRepository,
@InjectRepository(AssetEntity) private assetRepository: Repository<AssetEntity>,
@Inject(ICryptoRepository) private cryptoRepository: ICryptoRepository,
@Inject(IJobRepository) private jobRepository: IJobRepository,
@Inject(ILibraryRepository) private libraryRepository: ILibraryRepository,
@ -285,30 +282,6 @@ export class AssetService {
return Array.from(possibleSearchTerm).filter((x) => x != null && x != '');
}
async searchAsset(authUser: AuthUserDto, searchAssetDto: SearchAssetDto): Promise<AssetResponseDto[]> {
const query = `
SELECT a.*
FROM assets a
LEFT JOIN smart_info si ON a.id = si."assetId"
LEFT JOIN exif e ON a.id = e."assetId"
WHERE a."ownerId" = $1
AND
(
TO_TSVECTOR('english', ARRAY_TO_STRING(si.tags, ',')) @@ PLAINTO_TSQUERY('english', $2) OR
TO_TSVECTOR('english', ARRAY_TO_STRING(si.objects, ',')) @@ PLAINTO_TSQUERY('english', $2) OR
e."exifTextSearchableColumn" @@ PLAINTO_TSQUERY('english', $2)
);
`;
const searchResults: AssetEntity[] = await this.assetRepository.query(query, [
authUser.id,
searchAssetDto.searchTerm,
]);
return searchResults.map((asset) => mapAsset(asset));
}
async getCuratedLocation(authUser: AuthUserDto): Promise<CuratedLocationsResponseDto[]> {
return this._assetRepository.getLocationsByUserId(authUser.id);
}

View File

@ -1,6 +0,0 @@
import { IsNotEmpty } from 'class-validator';
export class SearchAssetDto {
@IsNotEmpty()
searchTerm!: string;
}

View File

@ -2794,19 +2794,6 @@ export interface SearchAlbumResponseDto {
*/
'total': number;
}
/**
*
* @export
* @interface SearchAssetDto
*/
export interface SearchAssetDto {
/**
*
* @type {string}
* @memberof SearchAssetDto
*/
'searchTerm': string;
}
/**
*
* @export
@ -7792,50 +7779,6 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
options: localVarRequestOptions,
};
},
/**
*
* @param {SearchAssetDto} searchAssetDto
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
searchAsset: async (searchAssetDto: SearchAssetDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'searchAssetDto' is not null or undefined
assertParamExists('searchAsset', 'searchAssetDto', searchAssetDto)
const localVarPath = `/asset/search`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication cookie required
// authentication api_key required
await setApiKeyToObject(localVarHeaderParameter, "x-api-key", configuration)
// authentication bearer required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(searchAssetDto, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {string} [id]
@ -8698,16 +8641,6 @@ export const AssetApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.runAssetJobs(assetJobsDto, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {SearchAssetDto} searchAssetDto
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async searchAsset(searchAssetDto: SearchAssetDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<AssetResponseDto>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.searchAsset(searchAssetDto, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @param {string} [id]
@ -9047,15 +8980,6 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
runAssetJobs(requestParameters: AssetApiRunAssetJobsRequest, options?: AxiosRequestConfig): AxiosPromise<void> {
return localVarFp.runAssetJobs(requestParameters.assetJobsDto, options).then((request) => request(axios, basePath));
},
/**
*
* @param {AssetApiSearchAssetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
searchAsset(requestParameters: AssetApiSearchAssetRequest, options?: AxiosRequestConfig): AxiosPromise<Array<AssetResponseDto>> {
return localVarFp.searchAsset(requestParameters.searchAssetDto, options).then((request) => request(axios, basePath));
},
/**
*
* @param {AssetApiSearchAssetsRequest} requestParameters Request parameters.
@ -9645,20 +9569,6 @@ export interface AssetApiRunAssetJobsRequest {
readonly assetJobsDto: AssetJobsDto
}
/**
* Request parameters for searchAsset operation in AssetApi.
* @export
* @interface AssetApiSearchAssetRequest
*/
export interface AssetApiSearchAssetRequest {
/**
*
* @type {SearchAssetDto}
* @memberof AssetApiSearchAsset
*/
readonly searchAssetDto: SearchAssetDto
}
/**
* Request parameters for searchAssets operation in AssetApi.
* @export
@ -10415,17 +10325,6 @@ export class AssetApi extends BaseAPI {
return AssetApiFp(this.configuration).runAssetJobs(requestParameters.assetJobsDto, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {AssetApiSearchAssetRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof AssetApi
*/
public searchAsset(requestParameters: AssetApiSearchAssetRequest, options?: AxiosRequestConfig) {
return AssetApiFp(this.configuration).searchAsset(requestParameters.searchAssetDto, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {AssetApiSearchAssetsRequest} requestParameters Request parameters.