Files
Mangarr/assets/vue/app/domain/activity/domain/entities/job.js
ext.jeremy.guillot@maxicoffee.domains 95f224d69a feat: enrich activity job display with manga/chapter context
- Add mangaTitle to ScrapingJob context at creation time
- Fix job.js constructor to map failureReason, attempts, maxAttempts, context from API
- JobItem: show readable type label, manga name, chapter number, source and attempts counter

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-11 22:23:09 +01:00

58 lines
1.4 KiB
JavaScript

export class Job {
constructor({
id,
type,
status,
progress = 0,
payload = {},
result = null,
error = null,
failureReason = null,
createdAt = new Date().toISOString(),
updatedAt = new Date().toISOString(),
attempts = 0,
maxAttempts = 1,
context = {}
}) {
this.id = id;
this.type = type;
this.status = status;
this.progress = progress;
this.payload = payload;
this.result = result;
this.error = failureReason ?? error;
this.createdAt = createdAt;
this.updatedAt = updatedAt;
this.attempts = attempts;
this.maxAttempts = maxAttempts;
this.context = context;
}
static create(data) {
return new Job(data);
}
isActive() {
return ['pending', 'in_progress'].includes(this.status);
}
hasError() {
return this.status === 'failed';
}
isCompleted() {
return this.status === 'completed';
}
}
export class JobCollection {
constructor(items, total, page, limit, hasNextPage, hasPreviousPage) {
this.items = items.map(item => Job.create(item));
this.total = total;
this.page = page;
this.limit = limit;
this.hasNextPage = hasNextPage;
this.hasPreviousPage = hasPreviousPage;
}
}