Enhance Gap Fill Offer Handling and Progression Path Logic
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m24s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 43s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m24s
- Updated `suggest_progression_path` to ensure unique gap fill offers are collected and added based on their IDs, improving the relevance of suggestions. - Refined the logic for setting `slot_status` and handling `gap_offer` and `proposal_key` in steps, enhancing clarity in progression path management. - Improved the `collectGapOffersFromApiResponse` function to consolidate gap offers from various sources, ensuring comprehensive offer retrieval. - Enhanced the handling of unfilled slots in `applyMatchStepsToSlots`, ensuring proper assignment of proposals and gap offers. - Added tests to validate the new logic for gap fill offers and slot assignments, ensuring robustness in path suggestion features.
This commit is contained in:
1 parent
6d130a7e09
commit
de939481ba
2 files changed
+53
-17
No files matched your search
@@ -214,10 +214,21 @@ const GAP_OFFER_SOURCE_PRIORITY = {
|
||||
}
|
||||
|
||||
export function collectGapOffersFromApiResponse(res) {
|
||||
const top = Array.isArray(res?.gap_fill_offers) ? res.gap_fill_offers : []
|
||||
if (top.length) return top
|
||||
const qa = res?.path_qa || {}
|
||||
return Array.isArray(qa?.gap_fill_offers) ? qa.gap_fill_offers : []
|
||||
const out = []
|
||||
const seen = new Set()
|
||||
const add = (offer) => {
|
||||
if (!offer || typeof offer !== 'object') return
|
||||
const id = offer.offer_id || `${offer.source}-${offer.roadmap_major_step_index}`
|
||||
if (seen.has(id)) return
|
||||
seen.add(id)
|
||||
out.push(offer)
|
||||
}
|
||||
for (const offer of res?.gap_fill_offers || []) add(offer)
|
||||
for (const offer of res?.path_qa?.gap_fill_offers || []) add(offer)
|
||||
for (const step of res?.steps || []) {
|
||||
if (step?.gap_offer) add(step.gap_offer)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** Maximal ein Angebot pro Slot — Roadmap-Lücken vor Brücken/QS. */
|
||||
@@ -805,13 +816,25 @@ export function applyMatchStepsToSlots(draft, apiSteps) {
|
||||
|
||||
const isProposal = Boolean(step.is_ai_proposal) || step.exercise_id == null
|
||||
const hasAiPayload = Boolean(step.ai_suggestion) || Boolean(step.proposal_key)
|
||||
if (isProposal && !hasAiPayload) {
|
||||
const wasLibrary =
|
||||
nextSlots[idx].primary?.kind === 'library' && nextSlots[idx].primary.exerciseId != null
|
||||
const mustClear = step.slot_status === 'unfilled' || step.slot_status === 'stripped'
|
||||
if (!wasLibrary || mustClear) {
|
||||
nextSlots[idx].primary = emptySlotExercise()
|
||||
}
|
||||
const isUnfilledSlot =
|
||||
step.slot_status === 'unfilled' ||
|
||||
step.slot_status === 'stripped' ||
|
||||
step.roadmap_match_source === 'unfilled' ||
|
||||
Boolean(step.gap_offer)
|
||||
if (isProposal && !hasAiPayload && isUnfilledSlot) {
|
||||
const offer = step.gap_offer || {}
|
||||
nextSlots[idx].primary = proposalSlotExercise({
|
||||
title:
|
||||
offer.title_hint ||
|
||||
step.roadmap_learning_goal ||
|
||||
step.title ||
|
||||
nextSlots[idx].learning_goal ||
|
||||
`Slot ${idx + 1}`,
|
||||
proposalKey: offer.offer_id || step.proposal_key || `roadmap-unfilled-${idx}`,
|
||||
aiSuggestion: offer.ai_suggestion || null,
|
||||
})
|
||||
} else if (isProposal && !hasAiPayload) {
|
||||
nextSlots[idx].primary = emptySlotExercise()
|
||||
} else if (isProposal) {
|
||||
nextSlots[idx].primary = proposalSlotExercise({
|
||||
title: step.title || nextSlots[idx].learning_goal,
|
||||
|
||||
Reference in new issue
Block a user