mirror of
https://github.com/immich-app/immich.git
synced 2024-12-26 10:50:29 +02:00
chore(server): remove unusuned endpoint/service/interface in asset-v1 (#9086)
This commit is contained in:
parent
3e03f5348f
commit
1d15cfb5f3
6
mobile/openapi/.openapi-generator/FILES
generated
6
mobile/openapi/.openapi-generator/FILES
generated
@ -60,8 +60,6 @@ doc/CreateLibraryDto.md
|
||||
doc/CreateProfileImageResponseDto.md
|
||||
doc/CreateTagDto.md
|
||||
doc/CreateUserDto.md
|
||||
doc/CuratedLocationsResponseDto.md
|
||||
doc/CuratedObjectsResponseDto.md
|
||||
doc/DeleteUserDto.md
|
||||
doc/DownloadApi.md
|
||||
doc/DownloadArchiveInfo.md
|
||||
@ -297,8 +295,6 @@ lib/model/create_library_dto.dart
|
||||
lib/model/create_profile_image_response_dto.dart
|
||||
lib/model/create_tag_dto.dart
|
||||
lib/model/create_user_dto.dart
|
||||
lib/model/curated_locations_response_dto.dart
|
||||
lib/model/curated_objects_response_dto.dart
|
||||
lib/model/delete_user_dto.dart
|
||||
lib/model/download_archive_info.dart
|
||||
lib/model/download_info_dto.dart
|
||||
@ -485,8 +481,6 @@ test/create_library_dto_test.dart
|
||||
test/create_profile_image_response_dto_test.dart
|
||||
test/create_tag_dto_test.dart
|
||||
test/create_user_dto_test.dart
|
||||
test/curated_locations_response_dto_test.dart
|
||||
test/curated_objects_response_dto_test.dart
|
||||
test/delete_user_dto_test.dart
|
||||
test/download_api_test.dart
|
||||
test/download_archive_info_test.dart
|
||||
|
BIN
mobile/openapi/README.md
generated
BIN
mobile/openapi/README.md
generated
Binary file not shown.
BIN
mobile/openapi/doc/AssetApi.md
generated
BIN
mobile/openapi/doc/AssetApi.md
generated
Binary file not shown.
BIN
mobile/openapi/doc/CuratedLocationsResponseDto.md
generated
BIN
mobile/openapi/doc/CuratedLocationsResponseDto.md
generated
Binary file not shown.
BIN
mobile/openapi/doc/CuratedObjectsResponseDto.md
generated
BIN
mobile/openapi/doc/CuratedObjectsResponseDto.md
generated
Binary file not shown.
BIN
mobile/openapi/lib/api.dart
generated
BIN
mobile/openapi/lib/api.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/api/asset_api.dart
generated
BIN
mobile/openapi/lib/api/asset_api.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/api_client.dart
generated
BIN
mobile/openapi/lib/api_client.dart
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
mobile/openapi/test/asset_api_test.dart
generated
BIN
mobile/openapi/test/asset_api_test.dart
generated
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1149,76 +1149,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/asset/curated-locations": {
|
||||
"get": {
|
||||
"operationId": "getCuratedLocations",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CuratedLocationsResponseDto"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Asset"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/asset/curated-objects": {
|
||||
"get": {
|
||||
"operationId": "getCuratedObjects",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CuratedObjectsResponseDto"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Asset"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/asset/device/{deviceId}": {
|
||||
"get": {
|
||||
"description": "Get all asset of a device that are in the database, ID only.",
|
||||
@ -1590,41 +1520,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/asset/search-terms": {
|
||||
"get": {
|
||||
"operationId": "getAssetSearchTerms",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"bearer": []
|
||||
},
|
||||
{
|
||||
"cookie": []
|
||||
},
|
||||
{
|
||||
"api_key": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Asset"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/asset/stack/parent": {
|
||||
"put": {
|
||||
"operationId": "updateStackParent",
|
||||
@ -8423,60 +8318,6 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"CuratedLocationsResponseDto": {
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "string"
|
||||
},
|
||||
"deviceAssetId": {
|
||||
"type": "string"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"resizePath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"city",
|
||||
"deviceAssetId",
|
||||
"deviceId",
|
||||
"id",
|
||||
"resizePath"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"CuratedObjectsResponseDto": {
|
||||
"properties": {
|
||||
"deviceAssetId": {
|
||||
"type": "string"
|
||||
},
|
||||
"deviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"object": {
|
||||
"type": "string"
|
||||
},
|
||||
"resizePath": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deviceAssetId",
|
||||
"deviceId",
|
||||
"id",
|
||||
"object",
|
||||
"resizePath"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"DeleteUserDto": {
|
||||
"properties": {
|
||||
"force": {
|
||||
|
@ -252,20 +252,6 @@ export type AssetBulkUploadCheckResult = {
|
||||
export type AssetBulkUploadCheckResponseDto = {
|
||||
results: AssetBulkUploadCheckResult[];
|
||||
};
|
||||
export type CuratedLocationsResponseDto = {
|
||||
city: string;
|
||||
deviceAssetId: string;
|
||||
deviceId: string;
|
||||
id: string;
|
||||
resizePath: string;
|
||||
};
|
||||
export type CuratedObjectsResponseDto = {
|
||||
deviceAssetId: string;
|
||||
deviceId: string;
|
||||
id: string;
|
||||
"object": string;
|
||||
resizePath: string;
|
||||
};
|
||||
export type CheckExistingAssetsDto = {
|
||||
deviceAssetIds: string[];
|
||||
deviceId: string;
|
||||
@ -1363,22 +1349,6 @@ export function checkBulkUpload({ assetBulkUploadCheckDto }: {
|
||||
body: assetBulkUploadCheckDto
|
||||
})));
|
||||
}
|
||||
export function getCuratedLocations(opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: CuratedLocationsResponseDto[];
|
||||
}>("/asset/curated-locations", {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function getCuratedObjects(opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: CuratedObjectsResponseDto[];
|
||||
}>("/asset/curated-objects", {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
/**
|
||||
* Get all asset of a device that are in the database, ID only.
|
||||
*/
|
||||
@ -1479,14 +1449,6 @@ export function getRandom({ count }: {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function getAssetSearchTerms(opts?: Oazapfts.RequestOpts) {
|
||||
return oazapfts.ok(oazapfts.fetchJson<{
|
||||
status: 200;
|
||||
data: string[];
|
||||
}>("/asset/search-terms", {
|
||||
...opts
|
||||
}));
|
||||
}
|
||||
export function updateStackParent({ updateStackParentDto }: {
|
||||
updateStackParentDto: UpdateStackParentDto;
|
||||
}, opts?: Oazapfts.RequestOpts) {
|
||||
|
@ -20,8 +20,6 @@ import {
|
||||
AssetBulkUploadCheckResponseDto,
|
||||
AssetFileUploadResponseDto,
|
||||
CheckExistingAssetsResponseDto,
|
||||
CuratedLocationsResponseDto,
|
||||
CuratedObjectsResponseDto,
|
||||
} from 'src/dtos/asset-v1-response.dto';
|
||||
import {
|
||||
AssetBulkUploadCheckDto,
|
||||
@ -111,21 +109,6 @@ export class AssetControllerV1 {
|
||||
await sendFile(res, next, () => this.service.serveThumbnail(auth, id, dto));
|
||||
}
|
||||
|
||||
@Get('/curated-objects')
|
||||
getCuratedObjects(@Auth() auth: AuthDto): Promise<CuratedObjectsResponseDto[]> {
|
||||
return this.service.getCuratedObject(auth);
|
||||
}
|
||||
|
||||
@Get('/curated-locations')
|
||||
getCuratedLocations(@Auth() auth: AuthDto): Promise<CuratedLocationsResponseDto[]> {
|
||||
return this.service.getCuratedLocation(auth);
|
||||
}
|
||||
|
||||
@Get('/search-terms')
|
||||
getAssetSearchTerms(@Auth() auth: AuthDto): Promise<string[]> {
|
||||
return this.service.getAssetSearchTerm(auth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all AssetEntity belong to the user
|
||||
*/
|
||||
|
@ -27,19 +27,3 @@ export class AssetFileUploadResponseDto {
|
||||
export class CheckExistingAssetsResponseDto {
|
||||
existingIds!: string[];
|
||||
}
|
||||
|
||||
export class CuratedLocationsResponseDto {
|
||||
id!: string;
|
||||
city!: string;
|
||||
resizePath!: string;
|
||||
deviceAssetId!: string;
|
||||
deviceId!: string;
|
||||
}
|
||||
|
||||
export class CuratedObjectsResponseDto {
|
||||
id!: string;
|
||||
object!: string;
|
||||
resizePath!: string;
|
||||
deviceAssetId!: string;
|
||||
deviceId!: string;
|
||||
}
|
||||
|
@ -130,19 +130,6 @@ export class GetAssetThumbnailDto {
|
||||
format: GetAssetThumbnailFormatEnum = GetAssetThumbnailFormatEnum.WEBP;
|
||||
}
|
||||
|
||||
export class SearchPropertiesDto {
|
||||
tags?: string[];
|
||||
objects?: string[];
|
||||
assetType?: string;
|
||||
orientation?: string;
|
||||
lensModel?: string;
|
||||
make?: string;
|
||||
model?: string;
|
||||
city?: string;
|
||||
state?: string;
|
||||
country?: string;
|
||||
}
|
||||
|
||||
export class ServeFileDto {
|
||||
@ValidateBoolean({ optional: true })
|
||||
@ApiProperty({ title: 'Is serve thumbnail (resize) file' })
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { CuratedLocationsResponseDto, CuratedObjectsResponseDto } from 'src/dtos/asset-v1-response.dto';
|
||||
import { AssetSearchDto, CheckExistingAssetsDto, SearchPropertiesDto } from 'src/dtos/asset-v1.dto';
|
||||
import { AssetSearchDto, CheckExistingAssetsDto } from 'src/dtos/asset-v1.dto';
|
||||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
|
||||
export interface AssetCheck {
|
||||
@ -13,10 +12,7 @@ export interface AssetOwnerCheck extends AssetCheck {
|
||||
|
||||
export interface IAssetRepositoryV1 {
|
||||
get(id: string): Promise<AssetEntity | null>;
|
||||
getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]>;
|
||||
getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]>;
|
||||
getAllByUserId(userId: string, dto: AssetSearchDto): Promise<AssetEntity[]>;
|
||||
getSearchPropertiesByUserId(userId: string): Promise<SearchPropertiesDto[]>;
|
||||
getAssetsByChecksums(userId: string, checksums: Buffer[]): Promise<AssetCheck[]>;
|
||||
getExistingAssets(userId: string, checkDuplicateAssetDto: CheckExistingAssetsDto): Promise<string[]>;
|
||||
getByOriginalPath(originalPath: string): Promise<AssetOwnerCheck | null>;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { CuratedLocationsResponseDto, CuratedObjectsResponseDto } from 'src/dtos/asset-v1-response.dto';
|
||||
import { AssetSearchDto, CheckExistingAssetsDto, SearchPropertiesDto } from 'src/dtos/asset-v1.dto';
|
||||
import { AssetSearchDto, CheckExistingAssetsDto } from 'src/dtos/asset-v1.dto';
|
||||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
import { AssetCheck, AssetOwnerCheck, IAssetRepositoryV1 } from 'src/interfaces/asset-v1.interface';
|
||||
import { OptionalBetween } from 'src/utils/database';
|
||||
@ -42,56 +41,6 @@ export class AssetRepositoryV1 implements IAssetRepositoryV1 {
|
||||
});
|
||||
}
|
||||
|
||||
getSearchPropertiesByUserId(userId: string): Promise<SearchPropertiesDto[]> {
|
||||
return this.assetRepository
|
||||
.createQueryBuilder('asset')
|
||||
.where('asset.ownerId = :userId', { userId: userId })
|
||||
.andWhere('asset.isVisible = true')
|
||||
.leftJoin('asset.exifInfo', 'ei')
|
||||
.leftJoin('asset.smartInfo', 'si')
|
||||
.select('si.tags', 'tags')
|
||||
.addSelect('si.objects', 'objects')
|
||||
.addSelect('asset.type', 'assetType')
|
||||
.addSelect('ei.orientation', 'orientation')
|
||||
.addSelect('ei."lensModel"', 'lensModel')
|
||||
.addSelect('ei.make', 'make')
|
||||
.addSelect('ei.model', 'model')
|
||||
.addSelect('ei.city', 'city')
|
||||
.addSelect('ei.state', 'state')
|
||||
.addSelect('ei.country', 'country')
|
||||
.distinctOn(['si.tags'])
|
||||
.getRawMany();
|
||||
}
|
||||
|
||||
getDetectedObjectsByUserId(userId: string): Promise<CuratedObjectsResponseDto[]> {
|
||||
return this.assetRepository.query(
|
||||
`
|
||||
SELECT DISTINCT ON (unnest(si.objects)) a.id, unnest(si.objects) as "object", a."previewPath" AS "resizePath", a."deviceAssetId", a."deviceId"
|
||||
FROM assets a
|
||||
LEFT JOIN smart_info si ON a.id = si."assetId"
|
||||
WHERE a."ownerId" = $1
|
||||
AND a."isVisible" = true
|
||||
AND si.objects IS NOT NULL
|
||||
`,
|
||||
[userId],
|
||||
);
|
||||
}
|
||||
|
||||
getLocationsByUserId(userId: string): Promise<CuratedLocationsResponseDto[]> {
|
||||
return this.assetRepository.query(
|
||||
`
|
||||
SELECT DISTINCT ON (e.city) a.id, e.city, a."previewPath" AS "resizePath", a."deviceAssetId", a."deviceId"
|
||||
FROM assets a
|
||||
LEFT JOIN exif e ON a.id = e."assetId"
|
||||
WHERE a."ownerId" = $1
|
||||
AND a."isVisible" = true
|
||||
AND e.city IS NOT NULL
|
||||
AND a.type = 'IMAGE';
|
||||
`,
|
||||
[userId],
|
||||
);
|
||||
}
|
||||
|
||||
get(id: string): Promise<AssetEntity | null> {
|
||||
return this.assetRepository.findOne({
|
||||
where: { id },
|
||||
|
@ -76,9 +76,6 @@ describe('AssetService', () => {
|
||||
assetRepositoryMockV1 = {
|
||||
get: vitest.fn(),
|
||||
getAllByUserId: vitest.fn(),
|
||||
getDetectedObjectsByUserId: vitest.fn(),
|
||||
getLocationsByUserId: vitest.fn(),
|
||||
getSearchPropertiesByUserId: vitest.fn(),
|
||||
getAssetsByChecksums: vitest.fn(),
|
||||
getExistingAssets: vitest.fn(),
|
||||
getByOriginalPath: vitest.fn(),
|
||||
|
@ -13,8 +13,6 @@ import {
|
||||
AssetRejectReason,
|
||||
AssetUploadAction,
|
||||
CheckExistingAssetsResponseDto,
|
||||
CuratedLocationsResponseDto,
|
||||
CuratedObjectsResponseDto,
|
||||
} from 'src/dtos/asset-v1-response.dto';
|
||||
import {
|
||||
AssetBulkUploadCheckDto,
|
||||
@ -156,48 +154,6 @@ export class AssetServiceV1 {
|
||||
});
|
||||
}
|
||||
|
||||
async getAssetSearchTerm(auth: AuthDto): Promise<string[]> {
|
||||
const possibleSearchTerm = new Set<string>();
|
||||
|
||||
const rows = await this.assetRepositoryV1.getSearchPropertiesByUserId(auth.user.id);
|
||||
|
||||
for (const row of rows) {
|
||||
// tags
|
||||
row.tags?.map((tag: string) => possibleSearchTerm.add(tag?.toLowerCase()));
|
||||
|
||||
// objects
|
||||
row.objects?.map((object: string) => possibleSearchTerm.add(object?.toLowerCase()));
|
||||
|
||||
// asset's tyoe
|
||||
possibleSearchTerm.add(row.assetType?.toLowerCase() || '');
|
||||
|
||||
// image orientation
|
||||
possibleSearchTerm.add(row.orientation?.toLowerCase() || '');
|
||||
|
||||
// Lens model
|
||||
possibleSearchTerm.add(row.lensModel?.toLowerCase() || '');
|
||||
|
||||
// Make and model
|
||||
possibleSearchTerm.add(row.make?.toLowerCase() || '');
|
||||
possibleSearchTerm.add(row.model?.toLowerCase() || '');
|
||||
|
||||
// Location
|
||||
possibleSearchTerm.add(row.city?.toLowerCase() || '');
|
||||
possibleSearchTerm.add(row.state?.toLowerCase() || '');
|
||||
possibleSearchTerm.add(row.country?.toLowerCase() || '');
|
||||
}
|
||||
|
||||
return [...possibleSearchTerm].filter((x) => x != null && x != '');
|
||||
}
|
||||
|
||||
async getCuratedLocation(auth: AuthDto): Promise<CuratedLocationsResponseDto[]> {
|
||||
return this.assetRepositoryV1.getLocationsByUserId(auth.user.id);
|
||||
}
|
||||
|
||||
async getCuratedObject(auth: AuthDto): Promise<CuratedObjectsResponseDto[]> {
|
||||
return this.assetRepositoryV1.getDetectedObjectsByUserId(auth.user.id);
|
||||
}
|
||||
|
||||
async checkExistingAssets(
|
||||
auth: AuthDto,
|
||||
checkExistingAssetsDto: CheckExistingAssetsDto,
|
||||
|
Loading…
Reference in New Issue
Block a user