From 0fc2f81f17cda7d6b1e56983bc04eaf5701013a9 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Mon, 28 Jan 2013 13:39:21 -0500 Subject: [PATCH] Reversing idle list and fixing insert/upsert --- plugins/downtime.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/downtime.go b/plugins/downtime.go index 23c496f..1ff19d7 100644 --- a/plugins/downtime.go +++ b/plugins/downtime.go @@ -31,7 +31,7 @@ func (ie idleEntries) Len() int { } 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) { @@ -96,7 +96,7 @@ func (p *DowntimePlugin) record(user string) { p.Coll.Find(bson.M{"nick": user}).One(&entry) if entry.Nick != user { // insert a new entry - p.Coll.Insert(idleEntry{ + p.Coll.Upsert(bson.M{"nick": user}, idleEntry{ Nick: user, LastSeen: time.Now(), })