Skip to content

Commit

Permalink
fix edge case in graphql's getfeed endpoint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jppade committed Sep 12, 2023
1 parent 850b2a9 commit d42ac5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/http/graphqlServer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module graphqlServer
go 1.17

require (
github.com/diadata-org/diadata v1.4.338
github.com/diadata-org/diadata v1.4.361
github.com/graph-gophers/graphql-go v1.1.0
github.com/sirupsen/logrus v1.8.1
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/graphql/resolver/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,10 +559,10 @@ func (r *DiaResolver) GetFeed(ctx context.Context, args struct {
log.Println("Generating blocks, Total Trades", len(trades))
log.Info("generating bins. Total bins: ", len(bins))

if len(trades) > 0 && len(bins) > 0 {
if len(bins) > 0 {
// In case the first bin is empty, look for the last trades before @starttime
// in order to select the most recent one with sufficient volume.
if !utils.IsInBin(trades[0].Time, bins[0]) {
if len(trades) == 0 || !utils.IsInBin(trades[0].Time, bins[0]) {
previousTrade, err := r.DS.GetTradesByFeedSelection(feedselection, []time.Time{endtime.AddDate(0, 0, -10)}, []time.Time{starttime}, lookbackTradesNumber)
if len(previousTrade) == 0 {
log.Error("get initial trade: ", err)
Expand Down

0 comments on commit d42ac5f

Please sign in to comment.