Skip to content

Commit

Permalink
feat: query UI (#1352)
Browse files Browse the repository at this point in the history
* log insert

* fix display error

* refactor code

* shorten status strings

* remove comment

* apply suggestion
  • Loading branch information
LexLuthr authored Apr 5, 2023
1 parent 699a08f commit 8f18a44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion retrievalmarket/rtvllog/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (d *RetrievalLogDB) list(ctx context.Context, offset int, limit int, where

dealState.PayloadCID, err = cid.Parse(payloadCid.String)
if err != nil {
return nil, fmt.Errorf("parsing payload cid '%s': %w", payloadCid.String, err)
dealState.PayloadCID = cid.Undef
}

if pieceCid.Valid && pieceCid.String != "" {
Expand Down
27 changes: 27 additions & 0 deletions retrievalmarket/rtvllog/retrieval_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,33 @@ func (r *RetrievalLog) OnQueryEvent(evt retrievalmarket.ProviderQueryEvent) {
"status", evt.Response.Status,
"msg", evt.Response.Message,
"err", evt.Error)

// Log failures to DB
st := &RetrievalDealState{
UnsealPrice: evt.Response.UnsealPrice,
Message: evt.Response.Message,
}
if evt.Error != nil {
st.Status = "Failed"
if evt.Response.Message == "" {
st.Message = evt.Error.Error()
}
} else {
if evt.Response.Status == retrievalmarket.QueryResponseUnavailable {
st.Status = "unavailable"
}
if evt.Response.Status == retrievalmarket.QueryResponseError {
st.Status = "errored"
}
}
if st.Status != "" {
r.dbUpdate(func() {
err := r.db.Insert(r.ctx, st)
if err != nil {
log.Errorw("failed to update retrieval deal logger db", "err", err)
}
})
}
}

// Called when there is a validation event.
Expand Down

0 comments on commit 8f18a44

Please sign in to comment.