graph2: Added unknownNick query
the build was successful

This commit is contained in:
2018-12-04 20:33:21 +01:00
parent 6310cbbc1e
commit 80e6c048c9
7 changed files with 54 additions and 5 deletions
+2 -2
View File
@@ -2,6 +2,6 @@ package models
// UnknownNick represents an unknown nick name.
type UnknownNick struct {
Nick string `bson:"_id"`
Weight int `bson:"weight"`
Nick string `bson:"_id"`
Score int `bson:"score"`
}
+1 -1
View File
@@ -17,7 +17,7 @@ func list(query interface{}, limit int) ([]models.UnknownNick, error) {
}
posts := make([]models.UnknownNick, 0, size)
err := collection.Find(query).Limit(limit).Sort("weight").All(&posts)
err := collection.Find(query).Limit(limit).Sort("-score").All(&posts)
if err != nil {
return nil, err
}
+2 -2
View File
@@ -44,8 +44,8 @@ func CancelUpdate() {
func CommitUpdate() error {
defer updateMutex.Unlock()
for nick, weight := range updateMap {
_, err := collection.UpsertId(nick, bson.M{"$set": bson.M{"weight": weight}})
for nick, score := range updateMap {
_, err := collection.UpsertId(nick, bson.M{"$set": bson.M{"score": score}})
if err != nil {
return err
}