Skip to content

Commit

Permalink
Make recommendation service optional (#1332)
Browse files Browse the repository at this point in the history
* support missing recommendation service

* support in view cart

* lint

* improve comment
  • Loading branch information
katzio authored Dec 1, 2022
1 parent 919b088 commit dfc78b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/frontend/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ func (fe *frontendServer) productHandler(w http.ResponseWriter, r *http.Request)
return
}

// ignores the error retrieving recommendations since it is not critical
recommendations, err := fe.getRecommendations(r.Context(), sessionID(r), []string{id})
if err != nil {
renderHTTPError(log, r, w, errors.Wrap(err, "failed to get product recommendations"), http.StatusInternalServerError)
return
log.WithField("error", err).Warn("failed to get product recommendations")
}

product := struct {
Expand Down Expand Up @@ -256,10 +256,10 @@ func (fe *frontendServer) viewCartHandler(w http.ResponseWriter, r *http.Request
return
}

// ignores the error retrieving recommendations since it is not critical
recommendations, err := fe.getRecommendations(r.Context(), sessionID(r), cartIDs(cart))
if err != nil {
renderHTTPError(log, r, w, errors.Wrap(err, "failed to get product recommendations"), http.StatusInternalServerError)
return
log.WithField("error", err).Warn("failed to get product recommendations")
}

shippingCost, err := fe.getShippingQuote(r.Context(), cart, currentCurrency(r))
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/templates/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ <h3 class="payment-method-heading">Payment Method</h3>

</main>

{{ if $.recommendations}}
{{ if $.recommendations }}
{{ template "recommendations" $.recommendations }}
{{ end }}

Expand Down

0 comments on commit dfc78b9

Please sign in to comment.