Skip to content

Commit

Permalink
Merge branch 'feat/nullable-dates' of https://github.com/immich-app/i…
Browse files Browse the repository at this point in the history
…mmich into feat/inline-offline-check
  • Loading branch information
etnoy committed Feb 6, 2025
2 parents 28d1857 + 32dc64f commit 04dca9a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 55 deletions.
24 changes: 0 additions & 24 deletions server/src/db.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,6 @@ 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 @@ -280,14 +266,6 @@ export interface NaturalearthCountries {
type: string;
}

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

export interface Partners {
createdAt: Generated<Timestamp>;
inTimeline: Generated<boolean>;
Expand Down Expand Up @@ -445,14 +423,12 @@ 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 @@ -164,8 +164,8 @@ export const mapAlbum = (entity: AlbumEntity, withAssets: boolean, auth?: AuthDt
const hasSharedLink = entity.sharedLinks?.length > 0;
const hasSharedUser = sharedUsers.length > 0;

let startDate = assets.at(0)?.localDateTime || undefined;
let endDate = assets.at(-1)?.localDateTime || undefined;
let startDate = assets.at(0)?.localDateTime;
let endDate = assets.at(-1)?.localDateTime;
// Swap dates if start date is greater than end date.
if (startDate && endDate && startDate > endDate) {
[startDate, endDate] = [endDate, startDate];
Expand Down
9 changes: 0 additions & 9 deletions server/src/dtos/asset.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ export class AssetStatsResponseDto {
total!: number;
}

export class AssetDatesDto {
dateTimeOriginal!: Date;
timeZone!: string | null;
localDateTime!: Date;
modifyDate!: Date;
fileCreatedAt!: Date;
fileModifiedAt!: Date;
}

export const mapStats = (stats: AssetStats): AssetStatsResponseDto => {
return {
images: stats[AssetType.IMAGE],
Expand Down
8 changes: 0 additions & 8 deletions server/src/services/asset-media.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,6 @@ describe(AssetMediaService.name, () => {
it('should throw an error if the requested preview file does not exist', async () => {
accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));

if (!assetStub.image.fileCreatedAt) {
throw new Error('fileCreatedAt is missing');
}

assetMock.getById.mockResolvedValue({
...assetStub.image,
files: [
Expand All @@ -568,10 +564,6 @@ describe(AssetMediaService.name, () => {
it('should fall back to preview if the requested thumbnail file does not exist', async () => {
accessMock.asset.checkOwnerAccess.mockResolvedValue(new Set([assetStub.image.id]));

if (!assetStub.image.fileCreatedAt) {
throw new Error('fileCreatedAt is missing');
}

assetMock.getById.mockResolvedValue({
...assetStub.image,
files: [
Expand Down
1 change: 1 addition & 0 deletions server/src/services/metadata.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ describe(MetadataService.name, () => {
id: assetStub.image.id,
duration: null,
fileCreatedAt: assetStub.image.fileCreatedAt,
fileModifiedAt: assetStub.image.fileModifiedAt,
localDateTime: assetStub.image.fileCreatedAt,
});
});
Expand Down
11 changes: 7 additions & 4 deletions server/src/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { SystemConfig } from 'src/config';
import { StorageCore } from 'src/cores/storage.core';
import { Exif } from 'src/db';
import { OnEvent, OnJob } from 'src/decorators';
import { AssetDatesDto } from 'src/dtos/asset.dto';
import { AssetFaceEntity } from 'src/entities/asset-face.entity';
import { AssetEntity } from 'src/entities/asset.entity';
import { PersonEntity } from 'src/entities/person.entity';
Expand Down Expand Up @@ -38,6 +37,13 @@ const EXIF_DATE_TAGS: Array<keyof Tags> = [
'DateTimeCreated',
];

class AssetDatesDto {
dateTimeOriginal!: Date;
timeZone!: string | null;
localDateTime!: Date;
modifyDate!: Date;
}

const validate = <T>(value: T): NonNullable<T> | null => {
// handle lists of numbers
if (Array.isArray(value)) {
Expand Down Expand Up @@ -464,7 +470,6 @@ export class MetadataService extends BaseService {
}
} else {
const motionAssetId = this.cryptoRepository.randomUUID();

const dates = this.getDates(asset, tags);
motionAsset = await this.assetRepository.create({
id: motionAssetId,
Expand Down Expand Up @@ -641,8 +646,6 @@ export class MetadataService extends BaseService {
timeZone,
localDateTime,
modifyDate,
fileCreatedAt,
fileModifiedAt,
};
}

Expand Down
8 changes: 0 additions & 8 deletions server/src/services/storage-template.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ describe(StorageTemplateService.name, () => {

expect(await sut.handleMigrationSingle({ id: asset.id })).toBe(JobStatus.SUCCESS);

if (asset.fileCreatedAt == null) {
throw new Error('fileCreatedAt must be set');
}

expect(moveMock.create).toHaveBeenCalledWith({
entityId: asset.id,
newPath: `upload/library/${user.id}/${asset.fileCreatedAt.getFullYear()}/${album.albumName}/${asset.originalFileName}`,
Expand All @@ -203,10 +199,6 @@ describe(StorageTemplateService.name, () => {

expect(await sut.handleMigrationSingle({ id: asset.id })).toBe(JobStatus.SUCCESS);

if (asset.fileCreatedAt == null) {
throw new Error('fileCreatedAt must be set');
}

const month = (asset.fileCreatedAt.getMonth() + 1).toString().padStart(2, '0');
expect(moveMock.create).toHaveBeenCalledWith({
entityId: asset.id,
Expand Down

0 comments on commit 04dca9a

Please sign in to comment.