Skip to content

Commit

Permalink
GetTopMiners hack for preview case when limit=5: removing extra rows …
Browse files Browse the repository at this point in the history
…from result (#30)
  • Loading branch information
ice-myles authored Sep 1, 2023
1 parent 0934ed0 commit 6b4397e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tokenomics/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,15 @@ func (r *repository) GetTopMiners(ctx context.Context, keyword string, limit, of
}
offset = nextOffset
}
defer func() {
sort.SliceStable(topMiners, sortTopMiners)
}()
sort.SliceStable(topMiners, sortTopMiners)
// This is the hack for preview GetTopMiners call with limit = 5 (we know this case for sure). We just remove all extra rows from result.
if limit == 5 {
bound := limit
if len(topMiners) < int(limit) {
bound = uint64(len(topMiners))
}
topMiners = topMiners[:bound]
}

return topMiners, nextOffset, nil
}
Expand Down

0 comments on commit 6b4397e

Please sign in to comment.