mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 13:17:42 +00:00
sort scores
This commit is contained in:
parent
8dc4ac350e
commit
e7faf73834
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -199,6 +200,10 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.SliceStable(tps.Children, func(i, j int) bool {
|
||||||
|
return tps.Children[i].Score > tps.Children[j].Score
|
||||||
|
})
|
||||||
|
|
||||||
posts := make([]string, tps.Count)
|
posts := make([]string, tps.Count)
|
||||||
for i, post := range tps.Children {
|
for i, post := range tps.Children {
|
||||||
posts[i] = fmt.Sprintf("%s: %d", post.Title, post.Score)
|
posts[i] = fmt.Sprintf("%s: %d", post.Title, post.Score)
|
||||||
|
|
Loading…
Reference in a new issue