feat: add quality column to conversion_jobs
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ CREATE TABLE IF NOT EXISTS conversion_jobs (
|
|||||||
output_mime_type VARCHAR(128) NULL,
|
output_mime_type VARCHAR(128) NULL,
|
||||||
input_size_bytes INT UNSIGNED NOT NULL,
|
input_size_bytes INT UNSIGNED NOT NULL,
|
||||||
output_size_bytes INT UNSIGNED NULL,
|
output_size_bytes INT UNSIGNED NULL,
|
||||||
|
quality SMALLINT UNSIGNED NULL,
|
||||||
conversion_duration_seconds DECIMAL(10,3) NULL,
|
conversion_duration_seconds DECIMAL(10,3) NULL,
|
||||||
error_message VARCHAR(255) NULL,
|
error_message VARCHAR(255) NULL,
|
||||||
error_log TEXT NULL,
|
error_log TEXT NULL,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ function toCamelJob(row) {
|
|||||||
outputMimeType: row.output_mime_type,
|
outputMimeType: row.output_mime_type,
|
||||||
inputSizeBytes: row.input_size_bytes,
|
inputSizeBytes: row.input_size_bytes,
|
||||||
outputSizeBytes: row.output_size_bytes,
|
outputSizeBytes: row.output_size_bytes,
|
||||||
|
quality: row.quality,
|
||||||
conversionDurationSeconds: row.conversion_duration_seconds,
|
conversionDurationSeconds: row.conversion_duration_seconds,
|
||||||
errorMessage: row.error_message,
|
errorMessage: row.error_message,
|
||||||
createdAt: row.created_at,
|
createdAt: row.created_at,
|
||||||
@@ -26,8 +27,8 @@ function toCamelJob(row) {
|
|||||||
export async function createJob(pool, job) {
|
export async function createJob(pool, job) {
|
||||||
await pool.query(
|
await pool.query(
|
||||||
`INSERT INTO conversion_jobs
|
`INSERT INTO conversion_jobs
|
||||||
(uuid, status, family, source_format, target_format, original_filename, input_path, input_mime_type, input_size_bytes, expires_at)
|
(uuid, status, family, source_format, target_format, original_filename, input_path, input_mime_type, input_size_bytes, expires_at, quality)
|
||||||
VALUES (?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?)`,
|
VALUES (?, 'pending', ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||||
[
|
[
|
||||||
job.uuid,
|
job.uuid,
|
||||||
job.family,
|
job.family,
|
||||||
@@ -38,6 +39,7 @@ export async function createJob(pool, job) {
|
|||||||
job.inputMimeType,
|
job.inputMimeType,
|
||||||
job.inputSizeBytes,
|
job.inputSizeBytes,
|
||||||
job.expiresAt,
|
job.expiresAt,
|
||||||
|
job.quality ?? null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -46,7 +48,7 @@ export async function getJobByUuid(pool, uuid) {
|
|||||||
const rows = await pool.query(
|
const rows = await pool.query(
|
||||||
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
||||||
input_path, output_path, input_mime_type, output_mime_type,
|
input_path, output_path, input_mime_type, output_mime_type,
|
||||||
input_size_bytes, output_size_bytes, conversion_duration_seconds,
|
input_size_bytes, output_size_bytes, quality, conversion_duration_seconds,
|
||||||
error_message, created_at, updated_at, expires_at, cleaned_at
|
error_message, created_at, updated_at, expires_at, cleaned_at
|
||||||
FROM conversion_jobs WHERE uuid = ?`,
|
FROM conversion_jobs WHERE uuid = ?`,
|
||||||
[uuid]
|
[uuid]
|
||||||
@@ -83,7 +85,7 @@ export async function findPendingJobs(pool, limit) {
|
|||||||
const rows = await pool.query(
|
const rows = await pool.query(
|
||||||
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
||||||
input_path, output_path, input_mime_type, output_mime_type,
|
input_path, output_path, input_mime_type, output_mime_type,
|
||||||
input_size_bytes, output_size_bytes, conversion_duration_seconds,
|
input_size_bytes, output_size_bytes, quality, conversion_duration_seconds,
|
||||||
error_message, created_at, updated_at, expires_at, cleaned_at
|
error_message, created_at, updated_at, expires_at, cleaned_at
|
||||||
FROM conversion_jobs WHERE status = 'pending' ORDER BY created_at ASC LIMIT ?`,
|
FROM conversion_jobs WHERE status = 'pending' ORDER BY created_at ASC LIMIT ?`,
|
||||||
[limit]
|
[limit]
|
||||||
@@ -95,7 +97,7 @@ export async function findExpiredJobs(pool) {
|
|||||||
const rows = await pool.query(
|
const rows = await pool.query(
|
||||||
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
`SELECT id, uuid, status, family, source_format, target_format, original_filename,
|
||||||
input_path, output_path, input_mime_type, output_mime_type,
|
input_path, output_path, input_mime_type, output_mime_type,
|
||||||
input_size_bytes, output_size_bytes, conversion_duration_seconds,
|
input_size_bytes, output_size_bytes, quality, conversion_duration_seconds,
|
||||||
error_message, created_at, updated_at, expires_at, cleaned_at
|
error_message, created_at, updated_at, expires_at, cleaned_at
|
||||||
FROM conversion_jobs WHERE expires_at < NOW() AND cleaned_at IS NULL`
|
FROM conversion_jobs WHERE expires_at < NOW() AND cleaned_at IS NULL`
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -62,6 +62,14 @@ describe('jobRepository', () => {
|
|||||||
expect(job.conversionDurationSeconds).toBeNull();
|
expect(job.conversionDurationSeconds).toBeNull();
|
||||||
expect(job.errorMessage).toBeNull();
|
expect(job.errorMessage).toBeNull();
|
||||||
expect(job.cleanedAt).toBeNull();
|
expect(job.cleanedAt).toBeNull();
|
||||||
|
expect(job.quality).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('stores and retrieves a numeric quality value', async () => {
|
||||||
|
await createJob(pool, baseJob({ uuid: '66666666-6666-4666-8666-666666666666', quality: 82 }));
|
||||||
|
|
||||||
|
const job = await getJobByUuid(pool, '66666666-6666-4666-8666-666666666666');
|
||||||
|
expect(job.quality).toBe(82);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns null for an unknown uuid', async () => {
|
it('returns null for an unknown uuid', async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user