mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix: memory generation (#25650)
This commit is contained in:
parent
e81faa1dbf
commit
141be5cbc9
7 changed files with 68 additions and 20 deletions
|
|
@ -116,8 +116,22 @@ where
|
||||||
"asset"."deletedAt" is null
|
"asset"."deletedAt" is null
|
||||||
and "asset"."visibility" != $1
|
and "asset"."visibility" != $1
|
||||||
and (
|
and (
|
||||||
"asset_job_status"."previewAt" is null
|
not exists (
|
||||||
or "asset_job_status"."thumbnailAt" is null
|
select
|
||||||
|
from
|
||||||
|
"asset_file"
|
||||||
|
where
|
||||||
|
"assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" = $2
|
||||||
|
)
|
||||||
|
or not exists (
|
||||||
|
select
|
||||||
|
from
|
||||||
|
"asset_file"
|
||||||
|
where
|
||||||
|
"assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" = $3
|
||||||
|
)
|
||||||
or "asset"."thumbhash" is null
|
or "asset"."thumbhash" is null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -292,7 +306,14 @@ from
|
||||||
where
|
where
|
||||||
"asset"."visibility" != $1
|
"asset"."visibility" != $1
|
||||||
and "asset"."deletedAt" is null
|
and "asset"."deletedAt" is null
|
||||||
and "job_status"."previewAt" is not null
|
and exists (
|
||||||
|
select
|
||||||
|
from
|
||||||
|
"asset_file"
|
||||||
|
where
|
||||||
|
"assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" = $2
|
||||||
|
)
|
||||||
and not exists (
|
and not exists (
|
||||||
select
|
select
|
||||||
from
|
from
|
||||||
|
|
@ -623,7 +644,14 @@ from
|
||||||
where
|
where
|
||||||
"asset"."visibility" != $1
|
"asset"."visibility" != $1
|
||||||
and "asset"."deletedAt" is null
|
and "asset"."deletedAt" is null
|
||||||
and "job_status"."previewAt" is not null
|
and exists (
|
||||||
|
select
|
||||||
|
from
|
||||||
|
"asset_file"
|
||||||
|
where
|
||||||
|
"assetId" = "asset"."id"
|
||||||
|
and "asset_file"."type" = $2
|
||||||
|
)
|
||||||
order by
|
order by
|
||||||
"asset"."fileCreatedAt" desc
|
"asset"."fileCreatedAt" desc
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,8 +134,7 @@ with
|
||||||
"asset"
|
"asset"
|
||||||
inner join "asset_job_status" on "asset"."id" = "asset_job_status"."assetId"
|
inner join "asset_job_status" on "asset"."id" = "asset_job_status"."assetId"
|
||||||
where
|
where
|
||||||
"asset_job_status"."previewAt" is not null
|
(asset."localDateTime" at time zone 'UTC')::date = today.date
|
||||||
and (asset."localDateTime" at time zone 'UTC')::date = today.date
|
|
||||||
and "asset"."ownerId" = any ($4::uuid[])
|
and "asset"."ownerId" = any ($4::uuid[])
|
||||||
and "asset"."visibility" = $5
|
and "asset"."visibility" = $5
|
||||||
and exists (
|
and exists (
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,22 @@ export class AssetJobRepository {
|
||||||
.innerJoin('asset_job_status', 'asset_job_status.assetId', 'asset.id')
|
.innerJoin('asset_job_status', 'asset_job_status.assetId', 'asset.id')
|
||||||
.where((eb) =>
|
.where((eb) =>
|
||||||
eb.or([
|
eb.or([
|
||||||
eb('asset_job_status.previewAt', 'is', null),
|
eb.not((eb) =>
|
||||||
eb('asset_job_status.thumbnailAt', 'is', null),
|
eb.exists((qb) =>
|
||||||
|
qb
|
||||||
|
.selectFrom('asset_file')
|
||||||
|
.whereRef('assetId', '=', 'asset.id')
|
||||||
|
.where('asset_file.type', '=', AssetFileType.Preview),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
eb.not((eb) =>
|
||||||
|
eb.exists((qb) =>
|
||||||
|
qb
|
||||||
|
.selectFrom('asset_file')
|
||||||
|
.whereRef('assetId', '=', 'asset.id')
|
||||||
|
.where('asset_file.type', '=', AssetFileType.Thumbnail),
|
||||||
|
),
|
||||||
|
),
|
||||||
eb('asset.thumbhash', 'is', null),
|
eb('asset.thumbhash', 'is', null),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
|
@ -157,7 +171,14 @@ export class AssetJobRepository {
|
||||||
.where('asset.visibility', '!=', AssetVisibility.Hidden)
|
.where('asset.visibility', '!=', AssetVisibility.Hidden)
|
||||||
.where('asset.deletedAt', 'is', null)
|
.where('asset.deletedAt', 'is', null)
|
||||||
.innerJoin('asset_job_status as job_status', 'assetId', 'asset.id')
|
.innerJoin('asset_job_status as job_status', 'assetId', 'asset.id')
|
||||||
.where('job_status.previewAt', 'is not', null);
|
.where((eb) =>
|
||||||
|
eb.exists((qb) =>
|
||||||
|
qb
|
||||||
|
.selectFrom('asset_file')
|
||||||
|
.whereRef('assetId', '=', 'asset.id')
|
||||||
|
.where('asset_file.type', '=', AssetFileType.Preview),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [], stream: true })
|
@GenerateSql({ params: [], stream: true })
|
||||||
|
|
|
||||||
|
|
@ -251,8 +251,6 @@ export class AssetRepository {
|
||||||
duplicatesDetectedAt: eb.ref('excluded.duplicatesDetectedAt'),
|
duplicatesDetectedAt: eb.ref('excluded.duplicatesDetectedAt'),
|
||||||
facesRecognizedAt: eb.ref('excluded.facesRecognizedAt'),
|
facesRecognizedAt: eb.ref('excluded.facesRecognizedAt'),
|
||||||
metadataExtractedAt: eb.ref('excluded.metadataExtractedAt'),
|
metadataExtractedAt: eb.ref('excluded.metadataExtractedAt'),
|
||||||
previewAt: eb.ref('excluded.previewAt'),
|
|
||||||
thumbnailAt: eb.ref('excluded.thumbnailAt'),
|
|
||||||
ocrAt: eb.ref('excluded.ocrAt'),
|
ocrAt: eb.ref('excluded.ocrAt'),
|
||||||
},
|
},
|
||||||
values[0],
|
values[0],
|
||||||
|
|
@ -361,7 +359,6 @@ export class AssetRepository {
|
||||||
.selectFrom('asset')
|
.selectFrom('asset')
|
||||||
.selectAll('asset')
|
.selectAll('asset')
|
||||||
.innerJoin('asset_job_status', 'asset.id', 'asset_job_status.assetId')
|
.innerJoin('asset_job_status', 'asset.id', 'asset_job_status.assetId')
|
||||||
.where('asset_job_status.previewAt', 'is not', null)
|
|
||||||
.where(sql`(asset."localDateTime" at time zone 'UTC')::date`, '=', sql`today.date`)
|
.where(sql`(asset."localDateTime" at time zone 'UTC')::date`, '=', sql`today.date`)
|
||||||
.where('asset.ownerId', '=', anyUuid(ownerIds))
|
.where('asset.ownerId', '=', anyUuid(ownerIds))
|
||||||
.where('asset.visibility', '=', AssetVisibility.Timeline)
|
.where('asset.visibility', '=', AssetVisibility.Timeline)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { Kysely, sql } from 'kysely';
|
||||||
|
|
||||||
|
export async function up(db: Kysely<any>): Promise<void> {
|
||||||
|
await sql`ALTER TABLE "asset_job_status" DROP COLUMN "previewAt";`.execute(db);
|
||||||
|
await sql`ALTER TABLE "asset_job_status" DROP COLUMN "thumbnailAt";`.execute(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(db: Kysely<any>): Promise<void> {
|
||||||
|
await sql`ALTER TABLE "asset_job_status" ADD "previewAt" timestamp with time zone;`.execute(db);
|
||||||
|
await sql`ALTER TABLE "asset_job_status" ADD "thumbnailAt" timestamp with time zone;`.execute(db);
|
||||||
|
}
|
||||||
|
|
@ -15,12 +15,6 @@ export class AssetJobStatusTable {
|
||||||
@Column({ type: 'timestamp with time zone', nullable: true })
|
@Column({ type: 'timestamp with time zone', nullable: true })
|
||||||
duplicatesDetectedAt!: Timestamp | null;
|
duplicatesDetectedAt!: Timestamp | null;
|
||||||
|
|
||||||
@Column({ type: 'timestamp with time zone', nullable: true })
|
|
||||||
previewAt!: Timestamp | null;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamp with time zone', nullable: true })
|
|
||||||
thumbnailAt!: Timestamp | null;
|
|
||||||
|
|
||||||
@Column({ type: 'timestamp with time zone', nullable: true })
|
@Column({ type: 'timestamp with time zone', nullable: true })
|
||||||
ocrAt!: Timestamp | null;
|
ocrAt!: Timestamp | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -601,8 +601,6 @@ const assetJobStatusInsert = (
|
||||||
duplicatesDetectedAt: date,
|
duplicatesDetectedAt: date,
|
||||||
facesRecognizedAt: date,
|
facesRecognizedAt: date,
|
||||||
metadataExtractedAt: date,
|
metadataExtractedAt: date,
|
||||||
previewAt: date,
|
|
||||||
thumbnailAt: date,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue