mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-16 23:18:48 +00:00
누락된 썸네일 생성 기능 구현
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user