Compare commits

..

2 Commits

Author SHA1 Message Date
Chris Sexton fc18fba2d8 counter: use absolute value for counter 2020-01-24 16:56:22 -05:00
Chris Sexton 918d37f591 Update go.yml 2020-01-24 16:54:09 -05:00
3 changed files with 7 additions and 5 deletions

View File

@ -7,10 +7,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.12
- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.12
go-version: 1.13.x
id: go
- name: Check out code into the Go module directory

View File

@ -73,10 +73,11 @@ func GetItems(db *sqlx.DB, nick string) ([]Item, error) {
}
func LeaderAll(db *sqlx.DB) ([]Item, error) {
s := `select id,item,nick,max(count) as count from counter group by item having count(nick) > 1 and max(count) > 1 order by count desc`
s := `select id,item,nick,count from (select id,item,nick,count,max(abs(count)) from counter group by item having count(nick) > 1 and max(abs(count)) > 1) order by count desc`
var items []Item
err := db.Select(&items, s)
if err != nil {
log.Error().Msgf("Error querying leaderboard: %w", err)
return nil, err
}
for i := range items {
@ -260,7 +261,7 @@ func (p *CounterPlugin) message(c bot.Connector, kind bot.Kind, message msg.Mess
its, err := cmd()
if err != nil {
log.Error().Err(err)
log.Error().Err(err).Msg("Error with leaderboard")
return false
} else if len(its) == 0 {
return false

View File

@ -4,10 +4,11 @@ package counter
import (
"fmt"
"github.com/velour/catbase/plugins/cli"
"strings"
"testing"
"github.com/velour/catbase/plugins/cli"
"github.com/stretchr/testify/assert"
"github.com/velour/catbase/bot"
"github.com/velour/catbase/bot/msg"