누락된 썸네일 생성 기능 구현

This commit is contained in:
static
2025-07-06 00:25:50 +09:00
parent 9e67920968
commit 3a637b14b4
11 changed files with 263 additions and 5 deletions

View File

@@ -345,7 +345,7 @@ export const getAllFileIdsByContentHmac = async (
.where("hmac_secret_key_version", "=", hskVersion)
.where("content_hmac", "=", contentHmac)
.execute();
return files.map(({ id }) => ({ id }));
return files.map(({ id }) => id);
};
export const getFile = async (userId: number, fileId: number) => {

View File

@@ -84,3 +84,27 @@ export const getFileThumbnail = async (userId: number, fileId: number) => {
} satisfies FileThumbnail)
: null;
};
export const getMissingFileThumbnails = async (userId: number, limit: number = 100) => {
const files = await db
.selectFrom("file")
.select("id")
.where("user_id", "=", userId)
.where((eb) =>
eb.or([eb("content_type", "like", "image/%"), eb("content_type", "like", "video/%")]),
)
.where((eb) =>
eb.not(
eb.exists(
eb
.selectFrom("thumbnail")
.select("thumbnail.id")
.whereRef("thumbnail.file_id", "=", "file.id")
.limit(1),
),
),
)
.limit(limit)
.execute();
return files.map((file) => file.id);
};