refactor: improve document segment naming logic by matching barcodes via page sets and including template name fallback
Build and Push Multi-Platform Images / build-and-push (push) Successful in 18s
Build and Push Multi-Platform Images / build-and-push (push) Successful in 18s
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
|||||||
ZoomInOutlined,
|
ZoomInOutlined,
|
||||||
ZoomOutOutlined,
|
ZoomOutOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { inboxApi, type InboxFile, type PostprocessActionResult } from '../api/inbox';
|
import { inboxApi, type InboxBarcode, type InboxFile, type PostprocessActionResult } from '../api/inbox';
|
||||||
import { paperlessApi } from '../api/paperless';
|
import { paperlessApi } from '../api/paperless';
|
||||||
|
|
||||||
const ZOOM_MIN = 0.5;
|
const ZOOM_MIN = 0.5;
|
||||||
@@ -35,7 +35,7 @@ function buildDocuments(
|
|||||||
pageCount: number,
|
pageCount: number,
|
||||||
splitPages: number[],
|
splitPages: number[],
|
||||||
deletedPages: number[],
|
deletedPages: number[],
|
||||||
barcodes: import('../api/inbox').InboxBarcode[],
|
barcodes: InboxBarcode[],
|
||||||
): DocumentSegment[] {
|
): DocumentSegment[] {
|
||||||
if (pageCount === 0) return [];
|
if (pageCount === 0) return [];
|
||||||
const deleted = new Set(deletedPages);
|
const deleted = new Set(deletedPages);
|
||||||
@@ -55,15 +55,14 @@ function buildDocuments(
|
|||||||
docs.push({ index: docs.length, pages: current, belegname: null });
|
docs.push({ index: docs.length, pages: current, belegname: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Belegname (DateinameTemplate) pro Segment bestimmen
|
// Belegname pro Segment: DateinameTemplate des zugehörigen Barcodes,
|
||||||
|
// Fallback auf templateName falls DateinameTemplate nicht konfiguriert.
|
||||||
|
const sortedBarcodes = [...barcodes].sort((a, b) => a.page - b.page);
|
||||||
return docs.map((seg) => {
|
return docs.map((seg) => {
|
||||||
let barcode: import('../api/inbox').InboxBarcode | undefined;
|
const pageSet = new Set(seg.pages);
|
||||||
if (seg.index === 0) {
|
const barcode = sortedBarcodes.find((b) => pageSet.has(b.page));
|
||||||
barcode = barcodes[0];
|
const belegname = barcode?.dateinameTemplate || barcode?.templateName || null;
|
||||||
} else {
|
return { ...seg, belegname };
|
||||||
barcode = barcodes.find((b) => b.splitBefore && b.page === seg.pages[0]);
|
|
||||||
}
|
|
||||||
return { ...seg, belegname: barcode?.dateinameTemplate ?? null };
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user