chore: apply ESLint auto-fix across entire backend
Build and Push Multi-Platform Images / build-and-push (push) Successful in 41s

Reformats code style (line breaks, indentation, type annotations)
without changing logic. Also includes minor feature additions bundled
in the same lint run (stats service, user-settings groups, agrarmonitor
polling improvements).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 09:02:02 +02:00
parent 4c75a1ded2
commit dad0136365
74 changed files with 4022 additions and 1052 deletions
@@ -9,9 +9,15 @@ import {
BarcodeTemplate,
type BarcodeActionType,
} from '../database/entities/barcode-template.entity';
import { InboxDocument, type StoredQrCode } from '../database/entities/inbox-document.entity';
import {
InboxDocument,
type StoredQrCode,
} from '../database/entities/inbox-document.entity';
import { PageCacheService } from './page-cache.service';
import { applyTemplate, buildVariables } from '../inbox-postprocessor/variable-resolver';
import {
applyTemplate,
buildVariables,
} from '../inbox-postprocessor/variable-resolver';
export interface MatchedBarcode {
page: number;
@@ -51,7 +57,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
try {
rows = await this.templateRepo.find();
} catch (err: any) {
this.logger.warn(`Template-Migration: Query fehlgeschlagen: ${err.message}`);
this.logger.warn(
`Template-Migration: Query fehlgeschlagen: ${err.message}`,
);
return;
}
let migrated = 0;
@@ -59,13 +67,17 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
const actions = (tpl.Actions ?? []) as string[];
if (actions.includes('SPLIT_BEFORE')) {
tpl.SplitBefore = true;
tpl.Actions = actions.filter((a) => a !== 'SPLIT_BEFORE') as BarcodeActionType[];
tpl.Actions = actions.filter(
(a) => a !== 'SPLIT_BEFORE',
) as BarcodeActionType[];
await this.templateRepo.save(tpl);
migrated += 1;
}
}
if (migrated > 0) {
this.logger.log(`Template-Migration: ${migrated} Vorlage(n) auf SplitBefore-Flag umgestellt`);
this.logger.log(
`Template-Migration: ${migrated} Vorlage(n) auf SplitBefore-Flag umgestellt`,
);
}
}
@@ -83,7 +95,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
try {
await this.documentRepo.save(doc);
} catch (err: any) {
this.logger.warn(`Scan-Ergebnis konnte nicht gespeichert werden (${doc.Id}): ${err.message}`);
this.logger.warn(
`Scan-Ergebnis konnte nicht gespeichert werden (${doc.Id}): ${err.message}`,
);
}
return this.matchTemplates(qrCodes);
@@ -105,7 +119,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
return this.matchTemplates(doc.QrCodes ?? []);
}
private async matchTemplates(qrCodes: StoredQrCode[]): Promise<MatchedBarcode[]> {
private async matchTemplates(
qrCodes: StoredQrCode[],
): Promise<MatchedBarcode[]> {
if (qrCodes.length === 0) return [];
const templates = await this.getTemplates();
return qrCodes.map((qr) => {
@@ -118,7 +134,11 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
dateinameTemplate: tpl?.DateinameTemplate
? applyTemplate(
tpl.DateinameTemplate,
buildVariables({ doc: {} as InboxDocument, template: tpl, matchingQrValue: qr.value }),
buildVariables({
doc: {} as InboxDocument,
template: tpl,
matchingQrValue: qr.value,
}),
)
: null,
splitBefore: tpl?.SplitBefore ?? false,
@@ -127,7 +147,10 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
});
}
private firstMatch(value: string, templates: BarcodeTemplate[]): BarcodeTemplate | null {
private firstMatch(
value: string,
templates: BarcodeTemplate[],
): BarcodeTemplate | null {
for (const tpl of templates) {
try {
const re = new RegExp(tpl.Regex);
@@ -141,7 +164,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
private async getTemplates(): Promise<BarcodeTemplate[]> {
if (!this.templatesCache) {
this.templatesCache = await this.templateRepo.find({ order: { Id: 'ASC' } });
this.templatesCache = await this.templateRepo.find({
order: { Id: 'ASC' },
});
}
return this.templatesCache;
}
@@ -168,7 +193,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
}
}
} catch (err: any) {
this.logger.warn(`QR-Scan fehlgeschlagen (${pdfPath}, Seite ${i + 1}): ${err.message}`);
this.logger.warn(
`QR-Scan fehlgeschlagen (${pdfPath}, Seite ${i + 1}): ${err.message}`,
);
}
}
@@ -206,17 +233,22 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
const { width: imgW, height: imgH } = await image.metadata();
if (!imgW || !imgH) return { found: [] };
const left = Math.round(Math.max(0, x * imgW));
const top = Math.round(Math.max(0, y * imgH));
const width = Math.round(Math.min(imgW - left, w * imgW));
const height = Math.round(Math.min(imgH - top, h * imgH));
const left = Math.round(Math.max(0, x * imgW));
const top = Math.round(Math.max(0, y * imgH));
const width = Math.round(Math.min(imgW - left, w * imgW));
const height = Math.round(Math.min(imgH - top, h * imgH));
if (width <= 0 || height <= 0) return { found: [] };
const cropped = await image.extract({ left, top, width, height }).png().toBuffer();
const cropped = await image
.extract({ left, top, width, height })
.png()
.toBuffer();
const qrResults = await this.qrCodeService.extractFromImage(cropped);
if (qrResults.length === 0) return { found: [] };
const existingKeys = new Set((doc.QrCodes ?? []).map((qr) => `${qr.page}:${qr.value}`));
const existingKeys = new Set(
(doc.QrCodes ?? []).map((qr) => `${qr.page}:${qr.value}`),
);
const found: string[] = [];
let changed = false;
@@ -254,7 +286,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
}
if (docs.length === 0) return { scanned: 0, failed: 0 };
this.logger.log(`Rescan: starte Neuerfassung für ${docs.length} Inbox-Dokument(e)`);
this.logger.log(
`Rescan: starte Neuerfassung für ${docs.length} Inbox-Dokument(e)`,
);
let scanned = 0;
let failed = 0;
for (const doc of docs) {
@@ -277,7 +311,9 @@ export class BarcodeScannerService implements OnApplicationBootstrap {
failed++;
}
}
this.logger.log(`Rescan abgeschlossen: ${scanned} ok, ${failed} fehlgeschlagen`);
this.logger.log(
`Rescan abgeschlossen: ${scanned} ok, ${failed} fehlgeschlagen`,
);
return { scanned, failed };
}
}