Uebernimm Enum-Listen und Filtergruppen in die Taxonomie, speichere Suchtreffer als Kandidaten und lasse CI das vorhandene API-Image nutzen.
Deploy Development / deploy (push) Successful in 2m6s
Test Suite / pytest-backend (push) Failing after 14s
Test Suite / smoke-dev (push) Successful in 1s
Test Suite / frontend-checks (push) Successful in 28s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-04 15:12:51 +02:00
1 parent 2117ca6b54
commit 68a8e3d945
23 files changed
+481 -118

No files matched your search

+9 -1
View File
@@ -94,6 +94,7 @@ export type ProjectCriterion = {
export type AvailableCriterion = {
criterion_definition_id: string;
label: string;
group_label?: string | null;
origin: string;
filter_type?: string | null;
unit?: string | null;
@@ -170,4 +171,11 @@ export type SourceCategory = {
product_category_id?: string | null;
source_url?: string | null;
};
export type SourceFilter = { label: string; external_filter_key: string; filter_type: string; status: string };
export type SourceFilter = {
label: string;
group_label?: string | null;
external_filter_key: string;
filter_type: string;
status: string;
options?: { source_value: string; normalized_value: unknown }[];
};
@@ -22,6 +22,28 @@ test("renders numeric threshold without notebook-specific fields", () => {
expect(screen.queryByLabelText("RAM GB")).not.toBeInTheDocument();
});
test("renders enum field list from learned options", () => {
render(
<CriteriaControl
criterion={{
...base,
label: "Hersteller",
filter_type: "ENUM",
operators: ["="],
options: [
{ source_value: "Apple", normalized_value: null },
{ source_value: "Lenovo", normalized_value: null },
],
}}
operator="="
value=""
onChange={() => undefined}
/>,
);
expect(screen.getByRole("option", { name: "Apple" })).toBeInTheDocument();
expect(screen.getByRole("option", { name: "Lenovo" })).toBeInTheDocument();
});
test("picks a single active source automatically", () => {
expect(pickSource([{ source: "geizhals", status: "ACTIVE" }])).toBe("geizhals");
expect(
+29 -3
View File
@@ -12,6 +12,9 @@ export function CriteriaControl({
onChange: (next: { operator: string; value: unknown }) => void;
}) {
const type = criterion.filter_type || "TEXT";
const options = criterion.options || [];
const optionValue = (option: { source_value: string; normalized_value: unknown }) =>
String(option.normalized_value ?? option.source_value);
return (
<div className="grid">
<label>
@@ -35,7 +38,30 @@ export function CriteriaControl({
<option value="false">nein</option>
</select>
</label>
) : type === "ENUM" || type === "MULTI_ENUM" ? (
) : type === "MULTI_ENUM" ? (
<fieldset className="option-list">
<legend>Werte</legend>
{options.map((option) => {
const selected = Array.isArray(value) ? value.map(String).includes(optionValue(option)) : false;
return (
<label key={option.source_value} className="option-item">
<input
type="checkbox"
checked={selected}
onChange={(event) => {
const current = Array.isArray(value) ? value.map(String) : [];
const next = event.target.checked
? [...current, optionValue(option)]
: current.filter((item) => item !== optionValue(option));
onChange({ operator, value: next });
}}
/>{" "}
{option.source_value}
</label>
);
})}
</fieldset>
) : options.length > 0 && (type === "ENUM" || type === "NUMERIC_THRESHOLD") ? (
<label>
Wert
<select
@@ -43,8 +69,8 @@ export function CriteriaControl({
onChange={(event) => onChange({ operator, value: event.target.value })}
>
<option value="">Bitte wählen</option>
{(criterion.options || []).map((option) => (
<option key={option.source_value} value={String(option.normalized_value ?? option.source_value)}>
{options.map((option) => (
<option key={option.source_value} value={optionValue(option)}>
{option.source_value}
</option>
))}
+17
View File
@@ -92,18 +92,35 @@ export function AdminPage() {
<table>
<thead>
<tr>
<th>Gruppe</th>
<th>Label</th>
<th>Filter</th>
<th>Typ</th>
<th>Werte</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{filters.data.filters.map((item) => (
<tr key={item.external_filter_key}>
<td>{item.group_label || "–"}</td>
<td>{item.label}</td>
<td>{item.external_filter_key}</td>
<td>{item.filter_type}</td>
<td>
{(item.options || []).length ? (
<details>
<summary>{item.options?.length} Werte</summary>
<ul className="option-list">
{(item.options || []).map((option) => (
<li key={option.source_value}>{option.source_value}</li>
))}
</ul>
</details>
) : (
"–"
)}
</td>
<td>{item.status}</td>
</tr>
))}
+1 -1
View File
@@ -32,7 +32,7 @@ export function CandidateDetailPage() {
</div>
<div className="card">
<h2>Attribute</h2>
{(item.current_dynamic_attributes || []).map((attr) => (
{(Array.isArray(item.current_dynamic_attributes) ? item.current_dynamic_attributes : []).map((attr) => (
<p key={attr.raw_name}>
{attr.raw_name}: {String(attr.normalized_value ?? "")} {attr.unit || ""}
</p>
+67 -7
View File
@@ -37,27 +37,87 @@ export function ProjectDetailPage() {
}
function Overview({ projectId }: { projectId: string }) {
const client = useQueryClient();
const searches = useQuery({ queryKey: ["searches", projectId], queryFn: () => api.searches(projectId) });
const searchId = searches.data?.items[0]?.id;
const runs = useQuery({
queryKey: ["runs", searchId],
queryFn: () => api.runs(searchId!),
enabled: Boolean(searchId),
});
const candidates = useQuery({
queryKey: ["candidates", projectId],
queryFn: () => api.candidates(projectId),
});
const run = useMutation({
mutationFn: async (searchId: string) => {
await api.generateQuery(searchId);
return api.runSearch(searchId);
mutationFn: async (id: string) => {
await api.generateQuery(id);
return api.runSearch(id);
},
onSuccess: () => {
client.invalidateQueries({ queryKey: ["searches", projectId] });
client.invalidateQueries({ queryKey: ["runs", searchId] });
client.invalidateQueries({ queryKey: ["candidates", projectId] });
client.invalidateQueries({ queryKey: ["project", projectId] });
client.invalidateQueries({ queryKey: ["projects"] });
},
});
if (searches.isLoading) return <LoadingState />;
const items = searches.data?.items || [];
if (!items.length) return <EmptyState>Noch kein SearchRun ausgeführt.</EmptyState>;
if (!items.length) return <EmptyState>Noch keine Suche angelegt.</EmptyState>;
const lastRun = runs.data?.items[0];
const found = candidates.data?.items || [];
return (
<div className="grid">
{items.map((search) => (
<div className="card" key={search.id}>
<div className="card grid" key={search.id}>
<p>Status: {search.status}</p>
<p className="muted">URL: {search.generated_url || "–"}</p>
{search.status === "OUT_OF_SYNC" ? <p>Suchparameter wurden geändert. Die externe Suche muss aktualisiert werden.</p> : null}
<button className="button" onClick={() => run.mutate(search.id)}>
Suche aktualisieren
{search.status === "TOO_BROAD" ? (
<p>Die Treffermenge ist zu groß. Die bereits geladenen Kandidaten bleiben gespeichert; die Suche enger fassen.</p>
) : null}
{lastRun ? (
<p>
Letzter Lauf: {lastRun.status} · {lastRun.result_count} Treffer · {lastRun.new_count} neu
{lastRun.error_code ? ` · ${lastRun.error_code}` : ""}
</p>
) : (
<p className="muted">Noch kein SearchRun ausgeführt.</p>
)}
{run.isError ? <ErrorState message={(run.error as Error).message} /> : null}
<button className="button" disabled={run.isPending} onClick={() => run.mutate(search.id)}>
{run.isPending ? "Sucht …" : "Suche aktualisieren"}
</button>
</div>
))}
<div className="card grid">
<p>{found.length} Kandidaten aus der Suche</p>
{found.length ? (
<table>
<thead>
<tr>
<th>Titel</th>
<th>Preis</th>
<th>Diff</th>
</tr>
</thead>
<tbody>
{found.slice(0, 12).map((item) => (
<tr key={item.candidate_id}>
<td>
<NavLink to={`/projects/${projectId}/candidates/${item.candidate_id}`}>{item.title || "Kandidat"}</NavLink>
</td>
<td>{item.current_best_price ? `${item.current_best_price} ${item.currency || ""}` : "–"}</td>
<td>{item.current_diff_status || "–"}</td>
</tr>
))}
</tbody>
</table>
) : (
<EmptyState>Noch keine Kandidaten übernommen.</EmptyState>
)}
</div>
</div>
);
}
+67 -40
View File
@@ -51,13 +51,19 @@ export function WizardPage() {
},
});
const sourceRow = sources.data.items.find((item) => item.source === source) || sources.data.items[0];
await api.createSearch(project.id, {
const search = await api.createSearch(project.id, {
source_id: sourceRow.source,
source_category_id: sourceRow.source_category_id,
});
try {
await api.generateQuery(search.id);
await api.runSearch(search.id);
} catch {
// Projekt und Suche bleiben erhalten; der Lauf kann auf der Projektseite wiederholt werden.
}
return project;
},
onSuccess: (project) => navigate(`/projects/${project.id}`),
onSuccess: (project) => navigate(`/projects/${project.id}/candidates`),
});
const sourceItems = sources.data?.items || [];
@@ -68,8 +74,21 @@ export function WizardPage() {
const items = criteria.data?.criteria || [];
const query = criterionQuery.trim().toLowerCase();
if (!query) return items;
return items.filter((item) => item.label.toLowerCase().includes(query));
return items.filter(
(item) =>
item.label.toLowerCase().includes(query) || (item.group_label || "").toLowerCase().includes(query),
);
}, [criteria.data, criterionQuery]);
const grouped = useMemo(() => {
const map = new Map<string, AvailableCriterion[]>();
for (const item of visible) {
const key = item.group_label || "Weitere";
const bucket = map.get(key) || [];
bucket.push(item);
map.set(key, bucket);
}
return [...map.entries()];
}, [visible]);
if (categories.isLoading) return <LoadingState />;
if (categories.isError) return <ErrorState message={(categories.error as Error).message} />;
@@ -161,48 +180,56 @@ export function WizardPage() {
Kriterien suchen
<input value={criterionQuery} onChange={(event) => setCriterionQuery(event.target.value)} />
</label>
{visible.map((item) => {
const on = selected.includes(item.criterion_definition_id);
return (
<div key={item.criterion_definition_id}>
<label>
<input
type="checkbox"
checked={on}
onChange={(event) => {
setSelected((current) =>
event.target.checked
? [...current, item.criterion_definition_id]
: current.filter((id) => id !== item.criterion_definition_id),
);
setDraft((current) => ({
...current,
[item.criterion_definition_id]: current[item.criterion_definition_id] || {
operator: item.operators[0] || ">=",
value: "",
},
}));
}}
/>{" "}
{item.label}
</label>
{on ? (
<CriteriaControl
criterion={item}
operator={draft[item.criterion_definition_id]?.operator || item.operators[0] || ">="}
value={draft[item.criterion_definition_id]?.value}
onChange={(next) => setDraft((current) => ({ ...current, [item.criterion_definition_id]: next }))}
/>
) : null}
</div>
);
})}
{grouped.map(([group, items]) => (
<fieldset key={group} className="criterion-group">
<legend>{group}</legend>
{items.map((item) => {
const on = selected.includes(item.criterion_definition_id);
return (
<div key={item.criterion_definition_id}>
<label>
<input
type="checkbox"
checked={on}
onChange={(event) => {
setSelected((current) =>
event.target.checked
? [...current, item.criterion_definition_id]
: current.filter((id) => id !== item.criterion_definition_id),
);
setDraft((current) => ({
...current,
[item.criterion_definition_id]: current[item.criterion_definition_id] || {
operator: item.operators[0] || ">=",
value: item.filter_type === "MULTI_ENUM" ? [] : "",
},
}));
}}
/>{" "}
{item.label}
{(item.options || []).length ? (
<span className="muted"> · {(item.options || []).length} Werte</span>
) : null}
</label>
{on ? (
<CriteriaControl
criterion={item}
operator={draft[item.criterion_definition_id]?.operator || item.operators[0] || ">="}
value={draft[item.criterion_definition_id]?.value}
onChange={(next) => setDraft((current) => ({ ...current, [item.criterion_definition_id]: next }))}
/>
) : null}
</div>
);
})}
</fieldset>
))}
</div>
) : null}
{create.isError ? <ErrorState message={(create.error as Error).message} /> : null}
<button className="button" disabled={!name || !categoryId || selected.length === 0 || create.isPending} onClick={() => create.mutate()}>
Projekt speichern
{create.isPending ? "Speichert und sucht …" : "Projekt speichern und suchen"}
</button>
</section>
);
+4
View File
@@ -28,6 +28,10 @@ th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #2a2d36; }
.button.secondary { background: #2a2d36; }
input, select { background: #111318; color: #e8eaed; border: 1px solid #3a3f4b; border-radius: 8px; padding: 8px; width: 100%; }
label { display: grid; gap: 6px; font-size: 14px; }
.criterion-group { border: 1px solid #2a2d36; border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.criterion-group legend { padding: 0 6px; color: #c5cad3; }
.option-list { margin: 8px 0 0; padding-left: 18px; }
.option-item { display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs a { padding: 6px 10px; border-radius: 8px; background: #181b22; }
.tabs a.active { background: #1d4ed8; }