Refactor Progression Comparison Logic and Enhance UI Components
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m19s
Deploy Development / deploy (push) Successful in 45s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m19s
- Introduced new utility functions for comparing slot differences, including `compareDiffKind`, `annotateCompareDiffKinds`, and various filtering functions to streamline the comparison process. - Updated `ProgressionGraphEditor` to utilize the new comparison logic, improving the handling of slot differences and user notifications. - Enhanced `ProgressionOptimizeCompareModal` to better manage proposed path suggestions, including clearer messaging and improved selection handling for optional replacements. - Adjusted frontend components to reflect changes in comparison logic, ensuring a more intuitive user experience in managing progression paths.
This commit is contained in:
1 parent
cec96ae473
commit
19bbcdaf50
3 files changed
+327
-152
No files matched your search
@@ -985,6 +985,51 @@ function actionableCompareSlotDiffs(diffs) {
|
||||
return (diffs || []).filter((d) => !d.trivial_id_swap)
|
||||
}
|
||||
|
||||
/** fill = leerer Slot + Bibliotheks-Treffer; replace = bestehende Übung tauschen; gap_only = nur KI-Angebot. */
|
||||
export function compareDiffKind(diff) {
|
||||
if (!diff || diff.trivial_id_swap) return 'skip'
|
||||
const hasBase = diff.baseline_exercise_id != null
|
||||
const hasProp = diff.proposed_exercise_id != null
|
||||
if (!hasBase && hasProp) return 'fill'
|
||||
if (hasBase && hasProp) return 'replace'
|
||||
if (!hasBase && !hasProp) return 'gap_only'
|
||||
if (hasBase && !hasProp) return 'replace'
|
||||
return 'skip'
|
||||
}
|
||||
|
||||
export function annotateCompareDiffKinds(diffs) {
|
||||
return (diffs || []).map((d) => ({
|
||||
...d,
|
||||
diff_kind: compareDiffKind(d),
|
||||
}))
|
||||
}
|
||||
|
||||
/** Nur übernehmbare Bibliotheks-Diffs (kein reines Titel-/Gap-Geplänkel). */
|
||||
export function compareDiffsForDialog(comparison) {
|
||||
const diffs = annotateCompareDiffKinds(
|
||||
compareSlotDiffs(comparison, { actionableOnly: true }),
|
||||
)
|
||||
return diffs.filter((d) => d.diff_kind === 'fill' || d.diff_kind === 'replace')
|
||||
}
|
||||
|
||||
export function recommendedCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'fill')
|
||||
}
|
||||
|
||||
export function optionalReplaceCompareDiffs(comparison) {
|
||||
return compareDiffsForDialog(comparison).filter((d) => d.diff_kind === 'replace')
|
||||
}
|
||||
|
||||
export function gapOnlyCompareDiffs(comparison) {
|
||||
return annotateCompareDiffKinds(
|
||||
compareSlotDiffs(comparison, { actionableOnly: true }),
|
||||
).filter((d) => d.diff_kind === 'gap_only')
|
||||
}
|
||||
|
||||
export function defaultSelectedCompareDiffs(comparison) {
|
||||
return recommendedCompareDiffs(comparison).map((d) => Number(d.roadmap_major_step_index))
|
||||
}
|
||||
|
||||
function mergeGapFillOffersFromSteps(steps, offers) {
|
||||
const merged = (offers || []).map((o) => ({ ...o }))
|
||||
const seen = new Set(merged.map((o) => o.offer_id).filter(Boolean))
|
||||
@@ -1006,10 +1051,16 @@ export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
const proposedSteps = Array.isArray(proposedRes?.steps) ? proposedRes.steps : []
|
||||
const baselineQa = baselineRes?.path_qa || null
|
||||
const pipelineQa = proposedRes?.path_qa || null
|
||||
const slotDiffs = annotateCompareSlotDiffs(
|
||||
buildProgressionSlotDiffs(baselineSteps, proposedSteps),
|
||||
const slotDiffs = annotateCompareDiffKinds(
|
||||
annotateCompareSlotDiffs(
|
||||
buildProgressionSlotDiffs(baselineSteps, proposedSteps),
|
||||
),
|
||||
)
|
||||
const actionableDiffs = actionableCompareSlotDiffs(slotDiffs)
|
||||
const dialogDiffs = actionableDiffs.filter(
|
||||
(d) => d.diff_kind === 'fill' || d.diff_kind === 'replace',
|
||||
)
|
||||
const recommendedDiffs = dialogDiffs.filter((d) => d.diff_kind === 'fill')
|
||||
const gapFillOffers = mergeGapFillOffersFromSteps(
|
||||
proposedSteps,
|
||||
proposedRes?.gap_fill_offers || [],
|
||||
@@ -1029,7 +1080,10 @@ export function buildProgressionComparePayload(baselineRes, proposedRes) {
|
||||
gap_fill_offers: gapFillOffers,
|
||||
slot_diffs: slotDiffs,
|
||||
slot_diffs_actionable: actionableDiffs,
|
||||
slot_diff_count: actionableDiffs.length,
|
||||
slot_diffs_dialog: dialogDiffs,
|
||||
slot_diffs_recommended: recommendedDiffs,
|
||||
slot_diff_count: dialogDiffs.length,
|
||||
slot_diff_count_recommended: recommendedDiffs.length,
|
||||
slot_diff_count_including_trivial: slotDiffs.length,
|
||||
slot_diffs_source: 'steps',
|
||||
path_qa: proposedQa,
|
||||
|
||||
Reference in new issue
Block a user