diff --git a/plugins/countdown/countdown.go b/plugins/countdown/countdown.go index d469e7b..34cff61 100644 --- a/plugins/countdown/countdown.go +++ b/plugins/countdown/countdown.go @@ -85,13 +85,10 @@ func (p *CountdownPlugin) clearBabblers() error { type counterArchive struct { counter.Item + ID uint64 `boltholdKey:"ID"` Year int } -func (ca counterArchive) Key() string { - return fmt.Sprintf("%d-%d", ca.Year, ca.ID) -} - func (p *CountdownPlugin) archiveCounters() error { year := time.Now().Year() allCounters := []counter.Item{} @@ -100,8 +97,8 @@ func (p *CountdownPlugin) archiveCounters() error { return err } for _, c := range allCounters { - ca := counterArchive{c, year} - err := p.store.Insert(ca.Key(), ca) + ca := counterArchive{Item: c, Year: year} + err := p.store.Insert(bh.NextSequence(), &ca) if err != nil { return err } diff --git a/plugins/countdown/countdown_test.go b/plugins/countdown/countdown_test.go index 6fe557b..da18c16 100644 --- a/plugins/countdown/countdown_test.go +++ b/plugins/countdown/countdown_test.go @@ -89,7 +89,7 @@ func TestArchiveCounters(t *testing.T) { } count, err := mb.Store().Count(counter.Item{}, &bh.Query{}) assert.Nil(t, err) - assert.Greater(t, count, 0) + assert.Equal(t, count, 3) err = cd.archiveCounters() assert.Nil(t, err) @@ -97,4 +97,8 @@ func TestArchiveCounters(t *testing.T) { count, err = mb.Store().Count(counter.Item{}, &bh.Query{}) assert.Nil(t, err) assert.Equal(t, count, 0) + + count, err = mb.Store().Count(counterArchive{}, &bh.Query{}) + assert.Nil(t, err) + assert.Equal(t, count, 3) }