mirror of
https://github.com/immich-app/immich.git
synced 2026-02-13 04:17:56 +03:00
fix: code review changes and errors
This commit is contained in:
@@ -17,3 +17,17 @@ where
|
||||
"assetId" = $1
|
||||
order by
|
||||
"sequence" asc
|
||||
|
||||
-- AssetEditRepository.getWithSyncInfo
|
||||
select
|
||||
"id",
|
||||
"assetId",
|
||||
"sequence",
|
||||
"action",
|
||||
"parameters"
|
||||
from
|
||||
"asset_edit"
|
||||
where
|
||||
"assetId" = $1
|
||||
order by
|
||||
"sequence" asc
|
||||
|
||||
@@ -514,6 +514,38 @@ where
|
||||
order by
|
||||
"asset_exif"."updateId" asc
|
||||
|
||||
-- SyncRepository.assetEdit.getDeletes
|
||||
select
|
||||
"asset_edit_audit"."id",
|
||||
"assetId"
|
||||
from
|
||||
"asset_edit_audit" as "asset_edit_audit"
|
||||
left join "asset" on "asset"."id" = "asset_edit_audit"."assetId"
|
||||
where
|
||||
"asset_edit_audit"."id" < $1
|
||||
and "asset_edit_audit"."id" > $2
|
||||
and "asset"."ownerId" = $3
|
||||
order by
|
||||
"asset_edit_audit"."id" asc
|
||||
|
||||
-- SyncRepository.assetEdit.getUpserts
|
||||
select
|
||||
"asset_edit"."id",
|
||||
"assetId",
|
||||
"action",
|
||||
"parameters",
|
||||
"sequence",
|
||||
"asset_edit"."updateId"
|
||||
from
|
||||
"asset_edit" as "asset_edit"
|
||||
inner join "asset" on "asset"."id" = "asset_edit"."assetId"
|
||||
where
|
||||
"asset_edit"."updateId" < $1
|
||||
and "asset_edit"."updateId" > $2
|
||||
and "asset"."ownerId" = $3
|
||||
order by
|
||||
"asset_edit"."updateId" asc
|
||||
|
||||
-- SyncRepository.assetFace.getDeletes
|
||||
select
|
||||
"asset_face_audit"."id",
|
||||
|
||||
@@ -9,9 +9,7 @@ import { DB } from 'src/schema';
|
||||
export class AssetEditRepository {
|
||||
constructor(@InjectKysely() private db: Kysely<DB>) {}
|
||||
|
||||
@GenerateSql({
|
||||
params: [DummyValue.UUID],
|
||||
})
|
||||
@GenerateSql({ params: [DummyValue.UUID] })
|
||||
replaceAll(assetId: string, edits: AssetEditActionItem[]): Promise<AssetEditActionItem[]> {
|
||||
return this.db.transaction().execute(async (trx) => {
|
||||
await trx.deleteFrom('asset_edit').where('assetId', '=', assetId).execute();
|
||||
@@ -28,9 +26,7 @@ export class AssetEditRepository {
|
||||
});
|
||||
}
|
||||
|
||||
@GenerateSql({
|
||||
params: [DummyValue.UUID],
|
||||
})
|
||||
@GenerateSql({ params: [DummyValue.UUID] })
|
||||
getAll(assetId: string): Promise<AssetEditActionItem[]> {
|
||||
return this.db
|
||||
.selectFrom('asset_edit')
|
||||
@@ -40,9 +36,7 @@ export class AssetEditRepository {
|
||||
.execute() as Promise<AssetEditActionItem[]>;
|
||||
}
|
||||
|
||||
@GenerateSql({
|
||||
params: [DummyValue.UUID],
|
||||
})
|
||||
@GenerateSql({ params: [DummyValue.UUID] })
|
||||
getWithSyncInfo(assetId: string) {
|
||||
return this.db
|
||||
.selectFrom('asset_edit')
|
||||
|
||||
@@ -502,7 +502,7 @@ class AssetExifSync extends BaseSync {
|
||||
}
|
||||
|
||||
class AssetEditSync extends BaseSync {
|
||||
@GenerateSql({ params: [dummyQueryOptions, DummyValue.UUID], stream: true })
|
||||
@GenerateSql({ params: [dummyQueryOptions], stream: true })
|
||||
getDeletes(options: SyncQueryOptions) {
|
||||
return this.auditQuery('asset_edit_audit', options)
|
||||
.select(['asset_edit_audit.id', 'assetId'])
|
||||
@@ -515,7 +515,7 @@ class AssetEditSync extends BaseSync {
|
||||
return this.auditCleanup('asset_edit_audit', daysAgo);
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [dummyQueryOptions, DummyValue.UUID], stream: true })
|
||||
@GenerateSql({ params: [dummyQueryOptions], stream: true })
|
||||
getUpserts(options: SyncQueryOptions) {
|
||||
return this.upsertQuery('asset_edit', options)
|
||||
.select(['asset_edit.id', 'assetId', 'action', 'parameters', 'sequence', 'asset_edit.updateId'])
|
||||
|
||||
@@ -15,6 +15,7 @@ export class AssetEditFactory {
|
||||
|
||||
static from(dto: AssetEditLike = {}) {
|
||||
const id = dto.id ?? newUuid();
|
||||
const updateId = dto.updateId ?? newUuid();
|
||||
|
||||
return new AssetEditFactory({
|
||||
id,
|
||||
@@ -22,6 +23,7 @@ export class AssetEditFactory {
|
||||
action: AssetEditAction.Crop,
|
||||
parameters: { x: 5, y: 6, width: 200, height: 100 },
|
||||
sequence: 1,
|
||||
updateId,
|
||||
...dto,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user