mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
chore: ran prettier
This commit is contained in:
parent
edaffc3788
commit
72c9003499
2 changed files with 58 additions and 44 deletions
|
|
@ -5,7 +5,7 @@ import {
|
|||
JobCountsDto,
|
||||
JobName,
|
||||
JobStatusDto,
|
||||
sendJobCommand
|
||||
sendJobCommand,
|
||||
} from '@immich/sdk';
|
||||
import { authenticate, BaseOptions, logError, withError } from 'src/utils';
|
||||
|
||||
|
|
@ -42,7 +42,11 @@ const JOB_STATUS_COLUMN_HEADERS: Readonly<Record<keyof JobCountsDto, string>> =
|
|||
* @param baseOptions Immich CLI base options.
|
||||
* @param commandOptions Options for the command, such as whether to output in JSON format.
|
||||
*/
|
||||
export async function getJobsStatus(jobName: JobName | undefined, baseOptions: BaseOptions, commandOptions: GetJobStatusOptions) {
|
||||
export async function getJobsStatus(
|
||||
jobName: JobName | undefined,
|
||||
baseOptions: BaseOptions,
|
||||
commandOptions: GetJobStatusOptions,
|
||||
) {
|
||||
await authenticate(baseOptions);
|
||||
|
||||
if (jobName) {
|
||||
|
|
@ -75,13 +79,15 @@ export async function startJob(jobName: JobName, baseOptions: BaseOptions, comma
|
|||
force = undefined;
|
||||
}
|
||||
|
||||
const [error, response] = await withError(sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Start,
|
||||
force,
|
||||
}
|
||||
}));
|
||||
const [error, response] = await withError(
|
||||
sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Start,
|
||||
force,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (error) {
|
||||
logError(error, `Failed to start job: ${jobName}. Got error`);
|
||||
|
|
@ -117,12 +123,14 @@ export async function pauseJobExecutions(jobName: JobName, baseOptions: BaseOpti
|
|||
|
||||
ensureJobNameIsValid(jobName);
|
||||
|
||||
const [error, response] = await withError(sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Pause
|
||||
}
|
||||
}));
|
||||
const [error, response] = await withError(
|
||||
sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Pause,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (error) {
|
||||
logError(error, `Failed to pause executions of job "${jobName}". Got error`);
|
||||
|
|
@ -143,17 +151,23 @@ export async function pauseJobExecutions(jobName: JobName, baseOptions: BaseOpti
|
|||
* @param baseOptions Immich CLI base options.
|
||||
* @param commandOptions Options for the command, such as whether to output in JSON format.
|
||||
*/
|
||||
export async function resumeJobExecutions(jobName: JobName, baseOptions: BaseOptions, commandOptions: ResumeJobOptions) {
|
||||
export async function resumeJobExecutions(
|
||||
jobName: JobName,
|
||||
baseOptions: BaseOptions,
|
||||
commandOptions: ResumeJobOptions,
|
||||
) {
|
||||
await authenticate(baseOptions);
|
||||
|
||||
ensureJobNameIsValid(jobName);
|
||||
|
||||
const [error, response] = await withError(sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Resume
|
||||
}
|
||||
}));
|
||||
const [error, response] = await withError(
|
||||
sendJobCommand({
|
||||
id: jobName,
|
||||
jobCommandDto: {
|
||||
command: JobCommand.Resume,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
if (error) {
|
||||
logError(error, `Failed to resume executions of job "${jobName}". Got error`);
|
||||
|
|
@ -207,19 +221,21 @@ async function getStatusOfAllJobs(commandOptions: CommonJobStatusOptions) {
|
|||
return;
|
||||
}
|
||||
|
||||
console.table(Object.entries(status).map(([name, status]) => {
|
||||
const row: Record<string, string | number | boolean> = {
|
||||
name,
|
||||
isQueueActive: status.queueStatus.isActive,
|
||||
isQueuePaused: status.queueStatus.isPaused,
|
||||
};
|
||||
console.table(
|
||||
Object.entries(status).map(([name, status]) => {
|
||||
const row: Record<string, string | number | boolean> = {
|
||||
name,
|
||||
isQueueActive: status.queueStatus.isActive,
|
||||
isQueuePaused: status.queueStatus.isPaused,
|
||||
};
|
||||
|
||||
for (const [key, value] of Object.entries(status.jobCounts)) {
|
||||
row[JOB_STATUS_COLUMN_HEADERS[key as keyof JobCountsDto]] = value;
|
||||
}
|
||||
for (const [key, value] of Object.entries(status.jobCounts)) {
|
||||
row[JOB_STATUS_COLUMN_HEADERS[key as keyof JobCountsDto]] = value;
|
||||
}
|
||||
|
||||
return row;
|
||||
}));
|
||||
return row;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -237,7 +253,7 @@ async function waitForJobCompletion(jobName: JobName): Promise<JobStatusDto> {
|
|||
return jobStatus;
|
||||
}
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ program
|
|||
.description('Remove stored credentials')
|
||||
.action(() => logout(program.opts()));
|
||||
|
||||
const jobsCommand = program.createCommand('jobs')
|
||||
.description('Manage background jobs');
|
||||
const jobsCommand = program.createCommand('jobs').description('Manage background jobs');
|
||||
|
||||
jobsCommand
|
||||
.command('pause')
|
||||
|
|
@ -68,7 +67,7 @@ jobsCommand
|
|||
.usage('<jobName> [options]')
|
||||
.addOption(
|
||||
new Option('-w, --wait', 'Wait for the job to complete before returning')
|
||||
.env("IMMICH_WAIT_JOB_COMPLETION")
|
||||
.env('IMMICH_WAIT_JOB_COMPLETION')
|
||||
.default(false),
|
||||
)
|
||||
.addOption(
|
||||
|
|
@ -77,7 +76,10 @@ jobsCommand
|
|||
.default(false),
|
||||
)
|
||||
.addOption(
|
||||
new Option('--all', 'Execute this job on all assets. Depending on the job, this may clear existing data previously created by the job')
|
||||
new Option(
|
||||
'--all',
|
||||
'Execute this job on all assets. Depending on the job, this may clear existing data previously created by the job',
|
||||
)
|
||||
.conflicts('refresh')
|
||||
.conflicts('onlyMissing'),
|
||||
)
|
||||
|
|
@ -87,16 +89,12 @@ jobsCommand
|
|||
.conflicts('all')
|
||||
.conflicts('refresh'),
|
||||
)
|
||||
.addOption(
|
||||
new Option('--refresh', '(Re)run this job on all assets')
|
||||
.conflicts('all')
|
||||
.conflicts('onlyMissing'),
|
||||
)
|
||||
.addOption(new Option('--refresh', '(Re)run this job on all assets').conflicts('all').conflicts('onlyMissing'))
|
||||
.argument('<jobName>', 'Name of the job to run')
|
||||
.action((jobName, options) => startJob(jobName, program.opts(), options));
|
||||
|
||||
jobsCommand
|
||||
.command("status")
|
||||
.command('status')
|
||||
.description('Get the status of all jobs or the status of a specific job')
|
||||
.usage('[jobName] [options]')
|
||||
.addOption(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue