@ -23,6 +23,8 @@ models:
model: git.aiterp.net/rpdata/api/models.Channel
ChannelsFilter:
model: git.aiterp.net/rpdata/api/models/channels.Filter
UnknownNick:
model: git.aiterp.net/rpdata/api/models.UnknownNick
Post:
model: git.aiterp.net/rpdata/api/models.Post
PostsFilter:
@ -0,0 +1,23 @@
package queries
import (
"context"
"git.aiterp.net/rpdata/api/models"
"git.aiterp.net/rpdata/api/models/unknownnicks"
"git.aiterp.net/rpdata/api/graph2/input"
)
/// Queries
func (r *resolver) UnknownNicks(ctx context.Context, filter *input.UnknownNicksFilter) ([]models.UnknownNick, error) {
limit := 100
if filter != nil {
if filter.Limit > 0 {
limit = filter.Limit
}
return unknownnicks.List(limit)
@ -26,6 +26,10 @@ type Query {
posts(filter: PostsFilter): [Post!]!
"List unknown nicks"
unknownNicks(filter: UnknownNicksFilter): [UnknownNick!]!
# Find log by ID
log(id: String!): Log!
@ -0,0 +1,20 @@
"""
An unknown nick is a nick found by the logbot that's not associated with
any characters. Many are going to be false positives, but most should be
useful in pointing out which characters are missing.
type UnknownNick {
"The IRC nick that's unknown."
nick: String!
"The amount of logs that contains the unknown nick."
score: Int!
Input for the unknownNicks query.
input UnknownNicksFilter {
"The highest amount of unknown nicks to return."
limit: Int!
@ -2,6 +2,6 @@ package models
// UnknownNick represents an unknown nick name.
type UnknownNick struct {
Nick string `bson:"_id"`
Weight int `bson:"weight"`
Score int `bson:"score"`
@ -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
@ -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}})
return err