mirror of https://github.com/velour/catbase.git
Reversing idle list and fixing insert/upsert
This commit is contained in:
parent
290d687be4
commit
0fc2f81f17
|
@ -31,7 +31,7 @@ func (ie idleEntries) Len() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ie idleEntries) Less(i, j int) bool {
|
func (ie idleEntries) Less(i, j int) bool {
|
||||||
return ie[i].LastSeen.After(ie[j].LastSeen)
|
return ie[i].LastSeen.Before(ie[j].LastSeen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ie idleEntries) Swap(i, j int) {
|
func (ie idleEntries) Swap(i, j int) {
|
||||||
|
@ -96,7 +96,7 @@ func (p *DowntimePlugin) record(user string) {
|
||||||
p.Coll.Find(bson.M{"nick": user}).One(&entry)
|
p.Coll.Find(bson.M{"nick": user}).One(&entry)
|
||||||
if entry.Nick != user {
|
if entry.Nick != user {
|
||||||
// insert a new entry
|
// insert a new entry
|
||||||
p.Coll.Insert(idleEntry{
|
p.Coll.Upsert(bson.M{"nick": user}, idleEntry{
|
||||||
Nick: user,
|
Nick: user,
|
||||||
LastSeen: time.Now(),
|
LastSeen: time.Now(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue