From 73bf8f343ac1644825607849d6ca3371ff1168ba Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Wed, 15 May 2024 15:17:48 -0400 Subject: [PATCH] chore(server): remove unused property (#9521) --- mobile/openapi/doc/CreateLibraryDto.md | Bin 697 -> 655 bytes mobile/openapi/doc/UpdateLibraryDto.md | Bin 615 -> 573 bytes .../openapi/lib/model/create_library_dto.dart | Bin 5171 -> 4480 bytes .../openapi/lib/model/update_library_dto.dart | Bin 4734 -> 4043 bytes .../openapi/test/create_library_dto_test.dart | Bin 1152 -> 1051 bytes .../openapi/test/update_library_dto_test.dart | Bin 955 -> 854 bytes open-api/immich-openapi-specs.json | 6 --- open-api/typescript-sdk/src/fetch-client.ts | 2 - server/src/cores/user.core.ts | 1 - server/src/dtos/library.dto.ts | 6 --- server/src/entities/library.entity.ts | 3 -- .../1715798702876-RemoveLibraryIsVisible.ts | 14 +++++++ server/src/queries/library.repository.sql | 20 ++-------- server/src/repositories/library.repository.ts | 2 - server/src/services/asset-v1.service.ts | 1 - server/src/services/library.service.spec.ts | 36 ------------------ server/src/services/library.service.ts | 1 - server/test/fixtures/library.stub.ts | 8 ---- 18 files changed, 17 insertions(+), 83 deletions(-) create mode 100644 server/src/migrations/1715798702876-RemoveLibraryIsVisible.ts diff --git a/mobile/openapi/doc/CreateLibraryDto.md b/mobile/openapi/doc/CreateLibraryDto.md index 01a2a0f91776167abbbb066ad63d40141bec73e9..f7d5c0ecfe9da2b3607c9c698a0a04677d7d31de 100644 GIT binary patch delta 12 TcmdnV+RwV7m~r!5Mj1u`9gG9z delta 52 zcmeBY-O0M4m{C2mI4rX`GbtxkOG}|fK}#zsKR*Y|1oEQu3raHc^AdAn6*dQY7mX<<|f|gcNetr&^3FJlR7nEe?=OyOEDoie5JPQEF CCJ~JQ diff --git a/mobile/openapi/lib/model/create_library_dto.dart b/mobile/openapi/lib/model/create_library_dto.dart index 93fb89b701835e33d161dabca9a37d0f295bfa27..532ddd68e3f480dfcd049203404fdf55baf61a1c 100644 GIT binary patch delta 39 xcmV+?0NDStD1ald(E+pN0p9_$H3cjIlZ6J?laL3=lWz#@v)&1H1GA6~qXthZ5Pbju delta 267 zcmZor-mJ0VA|q#Jaad+?W>QY-=3|Vn82OX(^KUomZwT6 zQhB90ISTd)1`1XPRf>}rvfdVfE3;LBGbdNEz2kuKCTFutNy9j)>ahy83MCnt#dt|4(JZMMlod;;_u(%%q&u&BqwGGx8_p=jYffAOxkE(wM~HTm@TOgxus}meooq zQhB90ISTd)1`1XPRf>~&Sl5WamD#GmnUlA%UZ{uj6clY0K>9Tms<{-vAgee(FSTC0$nQ=AIbr?0P|fK?~RaHx8)uFNzAjgrkxY=+FnaPzDb lauW-}5_3vZ{nJ7!3sP-B!C|KXGEYYV*(sWvS8^(`0RTLLY?A;0 diff --git a/mobile/openapi/test/create_library_dto_test.dart b/mobile/openapi/test/create_library_dto_test.dart index 1dd77af251e2df1509db4d84bcbf088b0d220910..eedb0d59d2f923860de09beb5bced95a208ac948 100644 GIT binary patch delta 12 TcmZqRoXxS}8`I`!W>rQ29!dlZ delta 43 scmbQu(ZIRk8xwC*etwQZW^q_%ab{A^BxWT}7&~>c9h2_nZ%nF;09d&XE&u=k diff --git a/mobile/openapi/test/update_library_dto_test.dart b/mobile/openapi/test/update_library_dto_test.dart index 222eb333bcf1f2854c9d28210d28e11bbb10d6d6..0db376dddb6914a978102b58380975cadd324faa 100644 GIT binary patch delta 11 ScmdnZevNIzH>Sza%n1M@I+Nz6)|Fm~!>J0{)9- { + await queryRunner.query(`ALTER TABLE "libraries" DROP COLUMN "isVisible"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "libraries" ADD "isVisible" boolean NOT NULL DEFAULT true`); + } + +} diff --git a/server/src/queries/library.repository.sql b/server/src/queries/library.repository.sql index 93a6fc97fb..3e655d6506 100644 --- a/server/src/queries/library.repository.sql +++ b/server/src/queries/library.repository.sql @@ -16,7 +16,6 @@ FROM "LibraryEntity"."updatedAt" AS "LibraryEntity_updatedAt", "LibraryEntity"."deletedAt" AS "LibraryEntity_deletedAt", "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt", - "LibraryEntity"."isVisible" AS "LibraryEntity_isVisible", "LibraryEntity__LibraryEntity_owner"."id" AS "LibraryEntity__LibraryEntity_owner_id", "LibraryEntity__LibraryEntity_owner"."name" AS "LibraryEntity__LibraryEntity_owner_name", "LibraryEntity__LibraryEntity_owner"."avatarColor" AS "LibraryEntity__LibraryEntity_owner_avatarColor", @@ -89,8 +88,7 @@ SELECT "LibraryEntity"."createdAt" AS "LibraryEntity_createdAt", "LibraryEntity"."updatedAt" AS "LibraryEntity_updatedAt", "LibraryEntity"."deletedAt" AS "LibraryEntity_deletedAt", - "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt", - "LibraryEntity"."isVisible" AS "LibraryEntity_isVisible" + "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt" FROM "libraries" "LibraryEntity" WHERE @@ -132,7 +130,6 @@ SELECT "LibraryEntity"."updatedAt" AS "LibraryEntity_updatedAt", "LibraryEntity"."deletedAt" AS "LibraryEntity_deletedAt", "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt", - "LibraryEntity"."isVisible" AS "LibraryEntity_isVisible", "LibraryEntity__LibraryEntity_owner"."id" AS "LibraryEntity__LibraryEntity_owner_id", "LibraryEntity__LibraryEntity_owner"."name" AS "LibraryEntity__LibraryEntity_owner_name", "LibraryEntity__LibraryEntity_owner"."avatarColor" AS "LibraryEntity__LibraryEntity_owner_avatarColor", @@ -156,12 +153,7 @@ FROM "LibraryEntity__LibraryEntity_owner"."deletedAt" IS NULL ) WHERE - ( - ( - ("LibraryEntity"."ownerId" = $1) - AND ("LibraryEntity"."isVisible" = $2) - ) - ) + ((("LibraryEntity"."ownerId" = $1))) AND ("LibraryEntity"."deletedAt" IS NULL) ORDER BY "LibraryEntity"."createdAt" ASC @@ -178,7 +170,6 @@ SELECT "LibraryEntity"."updatedAt" AS "LibraryEntity_updatedAt", "LibraryEntity"."deletedAt" AS "LibraryEntity_deletedAt", "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt", - "LibraryEntity"."isVisible" AS "LibraryEntity_isVisible", "LibraryEntity__LibraryEntity_owner"."id" AS "LibraryEntity__LibraryEntity_owner_id", "LibraryEntity__LibraryEntity_owner"."name" AS "LibraryEntity__LibraryEntity_owner_name", "LibraryEntity__LibraryEntity_owner"."avatarColor" AS "LibraryEntity__LibraryEntity_owner_avatarColor", @@ -218,7 +209,6 @@ SELECT "LibraryEntity"."updatedAt" AS "LibraryEntity_updatedAt", "LibraryEntity"."deletedAt" AS "LibraryEntity_deletedAt", "LibraryEntity"."refreshedAt" AS "LibraryEntity_refreshedAt", - "LibraryEntity"."isVisible" AS "LibraryEntity_isVisible", "LibraryEntity__LibraryEntity_owner"."id" AS "LibraryEntity__LibraryEntity_owner_id", "LibraryEntity__LibraryEntity_owner"."name" AS "LibraryEntity__LibraryEntity_owner_name", "LibraryEntity__LibraryEntity_owner"."avatarColor" AS "LibraryEntity__LibraryEntity_owner_avatarColor", @@ -239,10 +229,7 @@ FROM "libraries" "LibraryEntity" LEFT JOIN "users" "LibraryEntity__LibraryEntity_owner" ON "LibraryEntity__LibraryEntity_owner"."id" = "LibraryEntity"."ownerId" WHERE - ( - ("LibraryEntity"."isVisible" = $1) - AND (NOT ("LibraryEntity"."deletedAt" IS NULL)) - ) + ((NOT ("LibraryEntity"."deletedAt" IS NULL))) ORDER BY "LibraryEntity"."createdAt" ASC @@ -258,7 +245,6 @@ SELECT "libraries"."updatedAt" AS "libraries_updatedAt", "libraries"."deletedAt" AS "libraries_deletedAt", "libraries"."refreshedAt" AS "libraries_refreshedAt", - "libraries"."isVisible" AS "libraries_isVisible", COUNT("assets"."id") FILTER ( WHERE "assets"."type" = 'IMAGE' diff --git a/server/src/repositories/library.repository.ts b/server/src/repositories/library.repository.ts index b0350c14ec..25eb010356 100644 --- a/server/src/repositories/library.repository.ts +++ b/server/src/repositories/library.repository.ts @@ -67,7 +67,6 @@ export class LibraryRepository implements ILibraryRepository { return this.repository.find({ where: { ownerId, - isVisible: true, type, }, relations: { @@ -97,7 +96,6 @@ export class LibraryRepository implements ILibraryRepository { getAllDeleted(): Promise { return this.repository.find({ where: { - isVisible: true, deletedAt: Not(IsNull()), }, relations: { diff --git a/server/src/services/asset-v1.service.ts b/server/src/services/asset-v1.service.ts index 9667730fb3..bd6f540061 100644 --- a/server/src/services/asset-v1.service.ts +++ b/server/src/services/asset-v1.service.ts @@ -259,7 +259,6 @@ export class AssetServiceV1 { type: LibraryType.UPLOAD, importPaths: [], exclusionPatterns: [], - isVisible: true, }); } diff --git a/server/src/services/library.service.spec.ts b/server/src/services/library.service.spec.ts index f987fd1b57..fa45341784 100644 --- a/server/src/services/library.service.spec.ts +++ b/server/src/services/library.service.spec.ts @@ -830,7 +830,6 @@ describe(LibraryService.name, () => { type: LibraryType.EXTERNAL, importPaths: [], exclusionPatterns: [], - isVisible: true, }), ); }); @@ -860,37 +859,6 @@ describe(LibraryService.name, () => { type: LibraryType.EXTERNAL, importPaths: [], exclusionPatterns: [], - isVisible: true, - }), - ); - }); - - it('should create invisible', async () => { - libraryMock.create.mockResolvedValue(libraryStub.externalLibrary1); - await expect( - sut.create({ ownerId: authStub.admin.user.id, type: LibraryType.EXTERNAL, isVisible: false }), - ).resolves.toEqual( - expect.objectContaining({ - id: libraryStub.externalLibrary1.id, - type: LibraryType.EXTERNAL, - name: libraryStub.externalLibrary1.name, - ownerId: libraryStub.externalLibrary1.ownerId, - assetCount: 0, - importPaths: [], - exclusionPatterns: [], - createdAt: libraryStub.externalLibrary1.createdAt, - updatedAt: libraryStub.externalLibrary1.updatedAt, - refreshedAt: null, - }), - ); - - expect(libraryMock.create).toHaveBeenCalledWith( - expect.objectContaining({ - name: expect.any(String), - type: LibraryType.EXTERNAL, - importPaths: [], - exclusionPatterns: [], - isVisible: false, }), ); }); @@ -924,7 +892,6 @@ describe(LibraryService.name, () => { type: LibraryType.EXTERNAL, importPaths: ['/data/images', '/data/videos'], exclusionPatterns: [], - isVisible: true, }), ); }); @@ -972,7 +939,6 @@ describe(LibraryService.name, () => { type: LibraryType.EXTERNAL, importPaths: [], exclusionPatterns: ['*.tmp', '*.bak'], - isVisible: true, }), ); }); @@ -1002,7 +968,6 @@ describe(LibraryService.name, () => { type: LibraryType.UPLOAD, importPaths: [], exclusionPatterns: [], - isVisible: true, }), ); }); @@ -1032,7 +997,6 @@ describe(LibraryService.name, () => { type: LibraryType.UPLOAD, importPaths: [], exclusionPatterns: [], - isVisible: true, }), ); }); diff --git a/server/src/services/library.service.ts b/server/src/services/library.service.ts index a0d9b70d65..3c6e26a315 100644 --- a/server/src/services/library.service.ts +++ b/server/src/services/library.service.ts @@ -271,7 +271,6 @@ export class LibraryService { type: dto.type, importPaths: dto.importPaths ?? [], exclusionPatterns: dto.exclusionPatterns ?? [], - isVisible: dto.isVisible ?? true, }); this.logger.log(`Creating ${dto.type} library for ${dto.ownerId}}`); diff --git a/server/test/fixtures/library.stub.ts b/server/test/fixtures/library.stub.ts index dde250a7a1..bb95439d1c 100644 --- a/server/test/fixtures/library.stub.ts +++ b/server/test/fixtures/library.stub.ts @@ -16,7 +16,6 @@ export const libraryStub = { createdAt: new Date('2022-01-01'), updatedAt: new Date('2022-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: [], }), externalLibrary1: Object.freeze({ @@ -30,7 +29,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: [], }), externalLibrary2: Object.freeze({ @@ -44,7 +42,6 @@ export const libraryStub = { createdAt: new Date('2021-01-01'), updatedAt: new Date('2022-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: [], }), externalLibraryWithImportPaths1: Object.freeze({ @@ -58,7 +55,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: [], }), externalLibraryWithImportPaths2: Object.freeze({ @@ -72,7 +68,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: [], }), externalLibraryWithExclusionPattern: Object.freeze({ @@ -86,7 +81,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: ['**/dir1/**'], }), patternPath: Object.freeze({ @@ -100,7 +94,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: ['**/dir1/**'], }), hasImmichPaths: Object.freeze({ @@ -114,7 +107,6 @@ export const libraryStub = { createdAt: new Date('2023-01-01'), updatedAt: new Date('2023-01-01'), refreshedAt: null, - isVisible: true, exclusionPatterns: ['**/dir1/**'], }), };