mirror of
https://github.com/immich-app/immich.git
synced 2025-06-01 12:46:12 -04:00
chore(server): remove get person asset limit (#11597)
* chore(server): remover get person asset limit * sql * remove getPersonAsset endpoint * remove getPersonAsset endpoint * use search endpoint to get people * fix: server test * mobile linter * fix: server test * remove debuglog * deprecated endpoint * change page size on mobile * revert max size * fix test
This commit is contained in:
parent
0eacdf93eb
commit
f040c9fb38
@ -22,9 +22,6 @@ Future<List<PersonResponseDto>> getAllPeople(
|
|||||||
Future<RenderList> personAssets(PersonAssetsRef ref, String personId) async {
|
Future<RenderList> personAssets(PersonAssetsRef ref, String personId) async {
|
||||||
final PersonService personService = ref.read(personServiceProvider);
|
final PersonService personService = ref.read(personServiceProvider);
|
||||||
final assets = await personService.getPersonAssets(personId);
|
final assets = await personService.getPersonAssets(personId);
|
||||||
if (assets == null) {
|
|
||||||
return RenderList.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
final settings = ref.read(appSettingsServiceProvider);
|
final settings = ref.read(appSettingsServiceProvider);
|
||||||
final groupBy =
|
final groupBy =
|
||||||
|
@ -30,15 +30,41 @@ class PersonService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Asset>?> getPersonAssets(String id) async {
|
Future<List<Asset>> getPersonAssets(String id) async {
|
||||||
|
List<Asset> result = [];
|
||||||
|
var hasNext = true;
|
||||||
|
var currentPage = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final assets = await _apiService.peopleApi.getPersonAssets(id);
|
while (hasNext) {
|
||||||
if (assets == null) return null;
|
final response = await _apiService.searchApi.searchMetadata(
|
||||||
return await _db.assets.getAllByRemoteId(assets.map((e) => e.id));
|
MetadataSearchDto(
|
||||||
|
personIds: [id],
|
||||||
|
page: currentPage,
|
||||||
|
size: 1000,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.assets.nextPage == null) {
|
||||||
|
hasNext = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final assets = response.assets.items;
|
||||||
|
final mapAssets =
|
||||||
|
await _db.assets.getAllByRemoteId(assets.map((e) => e.id));
|
||||||
|
result.addAll(mapAssets);
|
||||||
|
|
||||||
|
currentPage++;
|
||||||
|
}
|
||||||
} catch (error, stack) {
|
} catch (error, stack) {
|
||||||
_log.severe("Error while fetching person assets", error, stack);
|
_log.severe("Error while fetching person assets", error, stack);
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<PersonResponseDto?> updateName(String id, String name) async {
|
Future<PersonResponseDto?> updateName(String id, String name) async {
|
||||||
|
1
mobile/openapi/README.md
generated
1
mobile/openapi/README.md
generated
@ -117,6 +117,7 @@ Class | Method | HTTP request | Description
|
|||||||
*AuthenticationApi* | [**signUpAdmin**](doc//AuthenticationApi.md#signupadmin) | **POST** /auth/admin-sign-up |
|
*AuthenticationApi* | [**signUpAdmin**](doc//AuthenticationApi.md#signupadmin) | **POST** /auth/admin-sign-up |
|
||||||
*AuthenticationApi* | [**validateAccessToken**](doc//AuthenticationApi.md#validateaccesstoken) | **POST** /auth/validateToken |
|
*AuthenticationApi* | [**validateAccessToken**](doc//AuthenticationApi.md#validateaccesstoken) | **POST** /auth/validateToken |
|
||||||
*DeprecatedApi* | [**getAboutInfo**](doc//DeprecatedApi.md#getaboutinfo) | **GET** /server-info/about |
|
*DeprecatedApi* | [**getAboutInfo**](doc//DeprecatedApi.md#getaboutinfo) | **GET** /server-info/about |
|
||||||
|
*DeprecatedApi* | [**getPersonAssets**](doc//DeprecatedApi.md#getpersonassets) | **GET** /people/{id}/assets |
|
||||||
*DeprecatedApi* | [**getServerConfig**](doc//DeprecatedApi.md#getserverconfig) | **GET** /server-info/config |
|
*DeprecatedApi* | [**getServerConfig**](doc//DeprecatedApi.md#getserverconfig) | **GET** /server-info/config |
|
||||||
*DeprecatedApi* | [**getServerFeatures**](doc//DeprecatedApi.md#getserverfeatures) | **GET** /server-info/features |
|
*DeprecatedApi* | [**getServerFeatures**](doc//DeprecatedApi.md#getserverfeatures) | **GET** /server-info/features |
|
||||||
*DeprecatedApi* | [**getServerStatistics**](doc//DeprecatedApi.md#getserverstatistics) | **GET** /server-info/statistics |
|
*DeprecatedApi* | [**getServerStatistics**](doc//DeprecatedApi.md#getserverstatistics) | **GET** /server-info/statistics |
|
||||||
|
56
mobile/openapi/lib/api/deprecated_api.dart
generated
56
mobile/openapi/lib/api/deprecated_api.dart
generated
@ -60,6 +60,62 @@ class DeprecatedApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.113.0
|
||||||
|
///
|
||||||
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<Response> getPersonAssetsWithHttpInfo(String id,) async {
|
||||||
|
// ignore: prefer_const_declarations
|
||||||
|
final path = r'/people/{id}/assets'
|
||||||
|
.replaceAll('{id}', id);
|
||||||
|
|
||||||
|
// ignore: prefer_final_locals
|
||||||
|
Object? postBody;
|
||||||
|
|
||||||
|
final queryParams = <QueryParam>[];
|
||||||
|
final headerParams = <String, String>{};
|
||||||
|
final formParams = <String, String>{};
|
||||||
|
|
||||||
|
const contentTypes = <String>[];
|
||||||
|
|
||||||
|
|
||||||
|
return apiClient.invokeAPI(
|
||||||
|
path,
|
||||||
|
'GET',
|
||||||
|
queryParams,
|
||||||
|
postBody,
|
||||||
|
headerParams,
|
||||||
|
formParams,
|
||||||
|
contentTypes.isEmpty ? null : contentTypes.first,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.113.0
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
///
|
||||||
|
/// * [String] id (required):
|
||||||
|
Future<List<AssetResponseDto>?> getPersonAssets(String id,) async {
|
||||||
|
final response = await getPersonAssetsWithHttpInfo(id,);
|
||||||
|
if (response.statusCode >= HttpStatus.badRequest) {
|
||||||
|
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
|
||||||
|
}
|
||||||
|
// When a remote server returns no body with a status of 204, we shall not decode it.
|
||||||
|
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
|
||||||
|
// FormatException when trying to decode an empty string.
|
||||||
|
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
|
||||||
|
final responseBody = await _decodeBodyBytes(response);
|
||||||
|
return (await apiClient.deserializeAsync(responseBody, 'List<AssetResponseDto>') as List)
|
||||||
|
.cast<AssetResponseDto>()
|
||||||
|
.toList(growable: false);
|
||||||
|
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// This property was deprecated in v1.107.0
|
/// This property was deprecated in v1.107.0
|
||||||
///
|
///
|
||||||
/// Note: This method returns the HTTP [Response].
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
7
mobile/openapi/lib/api/people_api.dart
generated
7
mobile/openapi/lib/api/people_api.dart
generated
@ -180,7 +180,10 @@ class PeopleApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs an HTTP 'GET /people/{id}/assets' operation and returns the [Response].
|
/// This property was deprecated in v1.113.0
|
||||||
|
///
|
||||||
|
/// Note: This method returns the HTTP [Response].
|
||||||
|
///
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
@ -210,6 +213,8 @@ class PeopleApi {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This property was deprecated in v1.113.0
|
||||||
|
///
|
||||||
/// Parameters:
|
/// Parameters:
|
||||||
///
|
///
|
||||||
/// * [String] id (required):
|
/// * [String] id (required):
|
||||||
|
@ -4115,6 +4115,8 @@
|
|||||||
},
|
},
|
||||||
"/people/{id}/assets": {
|
"/people/{id}/assets": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"deprecated": true,
|
||||||
|
"description": "This property was deprecated in v1.113.0",
|
||||||
"operationId": "getPersonAssets",
|
"operationId": "getPersonAssets",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@ -4154,8 +4156,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"People"
|
"People",
|
||||||
]
|
"Deprecated"
|
||||||
|
],
|
||||||
|
"x-immich-lifecycle": {
|
||||||
|
"deprecatedAt": "v1.113.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/people/{id}/merge": {
|
"/people/{id}/merge": {
|
||||||
|
@ -2267,6 +2267,9 @@ export function updatePerson({ id, personUpdateDto }: {
|
|||||||
body: personUpdateDto
|
body: personUpdateDto
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* This property was deprecated in v1.113.0
|
||||||
|
*/
|
||||||
export function getPersonAssets({ id }: {
|
export function getPersonAssets({ id }: {
|
||||||
id: string;
|
id: string;
|
||||||
}, opts?: Oazapfts.RequestOpts) {
|
}, opts?: Oazapfts.RequestOpts) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Body, Controller, Get, Inject, Next, Param, Post, Put, Query, Res } from '@nestjs/common';
|
import { Body, Controller, Get, Inject, Next, Param, Post, Put, Query, Res } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { NextFunction, Response } from 'express';
|
import { NextFunction, Response } from 'express';
|
||||||
|
import { EndpointLifecycle } from 'src/decorators';
|
||||||
import { BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto';
|
import { BulkIdResponseDto } from 'src/dtos/asset-ids.response.dto';
|
||||||
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
import { AssetResponseDto } from 'src/dtos/asset-response.dto';
|
||||||
import { AuthDto } from 'src/dtos/auth.dto';
|
import { AuthDto } from 'src/dtos/auth.dto';
|
||||||
@ -81,6 +82,7 @@ export class PersonController {
|
|||||||
await sendFile(res, next, () => this.service.getThumbnail(auth, id), this.logger);
|
await sendFile(res, next, () => this.service.getThumbnail(auth, id), this.logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EndpointLifecycle({ deprecatedAt: 'v1.113.0' })
|
||||||
@Get(':id/assets')
|
@Get(':id/assets')
|
||||||
@Authenticated()
|
@Authenticated()
|
||||||
getPersonAssets(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<AssetResponseDto[]> {
|
getPersonAssets(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto): Promise<AssetResponseDto[]> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user