From 9c923c038dc8612a4965e0ae77bf8253462b9302 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Fri, 27 Oct 2023 18:57:53 +0200 Subject: [PATCH] Reconcile the PiReply struct with recent changes to Pi (#1311) The Pi Evaluator stopped working because Pi changed its response structure. This patch reconciles the Pi changes with the struct we use to parse the reply. --- internal/engine/eval/package_intelligence/actions.go | 4 ++-- internal/engine/eval/package_intelligence/pi_rest_handler.go | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/engine/eval/package_intelligence/actions.go b/internal/engine/eval/package_intelligence/actions.go index f13bb84379..ce4e9df5b0 100644 --- a/internal/engine/eval/package_intelligence/actions.go +++ b/internal/engine/eval/package_intelligence/actions.go @@ -125,8 +125,8 @@ func (sph *summaryPrHandler) generateSummary() (string, error) { var rowBuf bytes.Buffer nonZeroAlternatives := make([]PiAlternative, 0) - for _, alt := range sph.trackedAlternatives[i].piReply.Alternatives { - if alt.Summary.Score != 0 { + for _, alt := range sph.trackedAlternatives[i].piReply.Alternatives.Packages { + if alt.Summary.Score > sph.trackedAlternatives[i].piReply.Summary.Score { nonZeroAlternatives = append(nonZeroAlternatives, alt) } } diff --git a/internal/engine/eval/package_intelligence/pi_rest_handler.go b/internal/engine/eval/package_intelligence/pi_rest_handler.go index 0ce1f0603c..99ba708e1c 100644 --- a/internal/engine/eval/package_intelligence/pi_rest_handler.go +++ b/internal/engine/eval/package_intelligence/pi_rest_handler.go @@ -67,7 +67,10 @@ type PiReply struct { Summary struct { Score float64 `json:"score"` } `json:"summary"` - Alternatives []PiAlternative `json:"alternatives"` + Alternatives struct { + Status string `json:"status"` + Packages []PiAlternative `json:"packages"` + } `json:"alternatives"` } func newPiClient(baseUrl string) *piClient {