fix: memory generation (#25650)

This commit is contained in:
Jason Rasmussen
2026-01-28 16:51:24 -05:00
committed by GitHub
parent e81faa1dbf
commit 141be5cbc9
7 changed files with 68 additions and 20 deletions

View File

@@ -116,8 +116,22 @@ where
"asset"."deletedAt" is null
and "asset"."visibility" != $1
and (
"asset_job_status"."previewAt" is null
or "asset_job_status"."thumbnailAt" is null
not exists (
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
)
@@ -292,7 +306,14 @@ from
where
"asset"."visibility" != $1
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 (
select
from
@@ -623,7 +644,14 @@ from
where
"asset"."visibility" != $1
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
"asset"."fileCreatedAt" desc

View File

@@ -134,8 +134,7 @@ with
"asset"
inner join "asset_job_status" on "asset"."id" = "asset_job_status"."assetId"
where
"asset_job_status"."previewAt" is not null
and (asset."localDateTime" at time zone 'UTC')::date = today.date
(asset."localDateTime" at time zone 'UTC')::date = today.date
and "asset"."ownerId" = any ($4::uuid[])
and "asset"."visibility" = $5
and exists (

View File

@@ -73,8 +73,22 @@ export class AssetJobRepository {
.innerJoin('asset_job_status', 'asset_job_status.assetId', 'asset.id')
.where((eb) =>
eb.or([
eb('asset_job_status.previewAt', 'is', null),
eb('asset_job_status.thumbnailAt', 'is', null),
eb.not((eb) =>
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),
]),
),
@@ -157,7 +171,14 @@ export class AssetJobRepository {
.where('asset.visibility', '!=', AssetVisibility.Hidden)
.where('asset.deletedAt', 'is', null)
.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 })

View File

@@ -251,8 +251,6 @@ export class AssetRepository {
duplicatesDetectedAt: eb.ref('excluded.duplicatesDetectedAt'),
facesRecognizedAt: eb.ref('excluded.facesRecognizedAt'),
metadataExtractedAt: eb.ref('excluded.metadataExtractedAt'),
previewAt: eb.ref('excluded.previewAt'),
thumbnailAt: eb.ref('excluded.thumbnailAt'),
ocrAt: eb.ref('excluded.ocrAt'),
},
values[0],
@@ -361,7 +359,6 @@ export class AssetRepository {
.selectFrom('asset')
.selectAll('asset')
.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('asset.ownerId', '=', anyUuid(ownerIds))
.where('asset.visibility', '=', AssetVisibility.Timeline)

View File

@@ -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);
}

View File

@@ -15,12 +15,6 @@ export class AssetJobStatusTable {
@Column({ type: 'timestamp with time zone', nullable: true })
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 })
ocrAt!: Timestamp | null;
}

View File

@@ -601,8 +601,6 @@ const assetJobStatusInsert = (
duplicatesDetectedAt: date,
facesRecognizedAt: date,
metadataExtractedAt: date,
previewAt: date,
thumbnailAt: date,
};
return {