Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
etnoy committed Jan 25, 2025
1 parent 6fbd580 commit f5f4059
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 51 deletions.
36 changes: 24 additions & 12 deletions mobile/openapi/lib/model/asset_response_dto.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions open-api/immich-openapi-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8450,10 +8450,12 @@
},
"fileCreatedAt": {
"format": "date-time",
"nullable": true,
"type": "string"
},
"fileModifiedAt": {
"format": "date-time",
"nullable": true,
"type": "string"
},
"hasMetadata": {
Expand Down Expand Up @@ -8486,6 +8488,7 @@
},
"localDateTime": {
"format": "date-time",
"nullable": true,
"type": "string"
},
"originalFileName": {
Expand Down
6 changes: 3 additions & 3 deletions open-api/typescript-sdk/src/fetch-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ export type AssetResponseDto = {
duplicateId?: string | null;
duration: string;
exifInfo?: ExifResponseDto;
fileCreatedAt: string;
fileModifiedAt: string;
fileCreatedAt: string | null;
fileModifiedAt: string | null;
hasMetadata: boolean;
id: string;
isArchived: boolean;
Expand All @@ -254,7 +254,7 @@ export type AssetResponseDto = {
/** This property was deprecated in v1.106.0 */
libraryId?: string | null;
livePhotoVideoId?: string | null;
localDateTime: string;
localDateTime: string | null;
originalFileName: string;
originalMimeType?: string;
originalPath: string;
Expand Down
32 changes: 28 additions & 4 deletions server/src/db.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ export interface Assets {
duplicateId: string | null;
duration: string | null;
encodedVideoPath: Generated<string | null>;
fileCreatedAt: Timestamp;
fileModifiedAt: Timestamp;
fileCreatedAt: Timestamp | null;
fileModifiedAt: Timestamp | null;
id: Generated<string>;
isArchived: Generated<boolean>;
isExternal: Generated<boolean>;
Expand All @@ -136,7 +136,7 @@ export interface Assets {
isVisible: Generated<boolean>;
libraryId: string | null;
livePhotoVideoId: string | null;
localDateTime: Timestamp;
localDateTime: Timestamp | null;
originalFileName: string;
originalPath: string;
ownerId: string;
Expand Down Expand Up @@ -214,6 +214,20 @@ export interface GeodataPlaces {
name: string;
}

export interface GeodataPlacesTmp {
admin1Code: string | null;
admin1Name: string | null;
admin2Code: string | null;
admin2Name: string | null;
alternateNames: string | null;
countryCode: string;
id: number;
latitude: number;
longitude: number;
modificationDate: Timestamp;
name: string;
}

export interface Libraries {
createdAt: Generated<Timestamp>;
deletedAt: Timestamp | null;
Expand Down Expand Up @@ -262,7 +276,15 @@ export interface NaturalearthCountries {
admin: string;
admin_a3: string;
coordinates: string;
id: number;
id: Generated<number>;
type: string;
}

export interface NaturalearthCountriesTmp {
admin: string;
admin_a3: string;
coordinates: string;
id: Generated<number>;
type: string;
}

Expand Down Expand Up @@ -418,12 +440,14 @@ export interface DB {
exif: Exif;
face_search: FaceSearch;
geodata_places: GeodataPlaces;
geodata_places_tmp: GeodataPlacesTmp;
libraries: Libraries;
memories: Memories;
memories_assets_assets: MemoriesAssetsAssets;
migrations: Migrations;
move_history: MoveHistory;
naturalearth_countries: NaturalearthCountries;
naturalearth_countries_tmp: NaturalearthCountriesTmp;
partners: Partners;
person: Person;
sessions: Sessions;
Expand Down
4 changes: 2 additions & 2 deletions server/src/dtos/album.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt
const hasSharedLink = entity.sharedLinks?.length > 0;
const hasSharedUser = sharedUsers.length > 0;

let startDate = getAssetDateTime(assets.at(0));
let endDate = getAssetDateTime(assets.at(-1));
let startDate = getAssetDateTime(assets.at(0)) ?? undefined;
let endDate = getAssetDateTime(assets.at(-1)) ?? undefined;
// Swap dates if start date is greater than end date.
if (startDate && endDate && startDate > endDate) {
[startDate, endDate] = [endDate, startDate];
Expand Down
6 changes: 3 additions & 3 deletions server/src/dtos/asset-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SanitizedAssetResponseDto {
type!: AssetType;
thumbhash!: string | null;
originalMimeType?: string;
localDateTime!: Date;
localDateTime!: Date | null;
duration!: string;
livePhotoVideoId?: string | null;
hasMetadata!: boolean;
Expand All @@ -36,8 +36,8 @@ export class AssetResponseDto extends SanitizedAssetResponseDto {
libraryId?: string | null;
originalPath!: string;
originalFileName!: string;
fileCreatedAt!: Date;
fileModifiedAt!: Date;
fileCreatedAt!: Date | null;
fileModifiedAt!: Date | null;
updatedAt!: Date;
isFavorite!: boolean;
isArchived!: boolean;
Expand Down
4 changes: 2 additions & 2 deletions server/src/queries/access.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ from
left join "users" on "users"."id" = "albumUsers"."usersId"
and "users"."deletedAt" is null
where
array["assets"."id", "assets"."livePhotoVideoId"] && array[$1]::uuid[]
array["assets"."id", "assets"."livePhotoVideoId"] && array[$1]::uuid []
and (
"albums"."ownerId" = $2
or "users"."id" = $3
Expand Down Expand Up @@ -136,7 +136,7 @@ where
"assets"."livePhotoVideoId",
"albumAssets"."id",
"albumAssets"."livePhotoVideoId"
] && array[$2]::uuid[]
] && array[$2]::uuid []

-- AccessRepository.authDevice.checkOwnerAccess
select
Expand Down
14 changes: 7 additions & 7 deletions server/src/queries/asset.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ with
where
"asset_job_status"."previewAt" is not null
and (assets."localDateTime" at time zone 'UTC')::date = today.date
and "assets"."ownerId" = any ($3::uuid[])
and "assets"."ownerId" = any ($3::uuid [])
and "assets"."isVisible" = $4
and "assets"."isArchived" = $5
and exists (
Expand Down Expand Up @@ -72,7 +72,7 @@ select
from
"assets"
where
"assets"."id" = any ($1::uuid[])
"assets"."id" = any ($1::uuid [])

-- AssetRepository.getByIdsWithAllRelations
select
Expand Down Expand Up @@ -130,7 +130,7 @@ from
"asset_stack"."id"
) as "stacked_assets" on "asset_stack"."id" is not null
where
"assets"."id" = any ($2::uuid[])
"assets"."id" = any ($2::uuid [])

-- AssetRepository.deleteAll
delete from "assets"
Expand Down Expand Up @@ -182,16 +182,16 @@ update "assets"
set
"deviceId" = $1
where
"id" = any ($2::uuid[])
"id" = any ($2::uuid [])

-- AssetRepository.updateDuplicates
update "assets"
set
"duplicateId" = $1
where
(
"duplicateId" = any ($2::uuid[])
or "id" = any ($3::uuid[])
"duplicateId" = any ($2::uuid [])
or "id" = any ($3::uuid [])
)

-- AssetRepository.getByChecksum
Expand Down Expand Up @@ -438,7 +438,7 @@ from
"asset_stack"."id"
) as "stacked_assets" on "asset_stack"."id" is not null
where
"assets"."ownerId" = any ($1::uuid[])
"assets"."ownerId" = any ($1::uuid [])
and "isVisible" = $2
and "updatedAt" > $3
limit
Expand Down
Loading

0 comments on commit f5f4059

Please sign in to comment.