Skip to content

Commit

Permalink
Reconcile the PiReply struct with recent changes to Pi (#1311)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhrozek authored Oct 27, 2023
1 parent 4a75849 commit 9c923c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/engine/eval/package_intelligence/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
5 changes: 4 additions & 1 deletion internal/engine/eval/package_intelligence/pi_rest_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9c923c0

Please sign in to comment.