Private
Public Access
1
0

Calculate netspeed points, too
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-07-16 02:40:50 -07:00
parent 1f7973e885
commit 27c8bc4776
11 changed files with 281 additions and 123 deletions

View File

@@ -9,7 +9,6 @@ import (
"sort"
"time"
"github.com/ClickHouse/clickhouse-go/v2"
"golang.org/x/exp/slog"
)
@@ -31,10 +30,10 @@ func (s UserCountry) Less(i, j int) bool {
return s[i].IPv4 > s[j].IPv4
}
func (d *ClickHouse) UserCountryData(ctx context.Context, conn clickhouse.Conn) (*UserCountry, error) {
func (d *ClickHouse) UserCountryData(ctx context.Context) (*UserCountry, error) {
// rows, err := conn.Query(ctx, "select dt,UserCC,Qtype,sum(queries) as queries from by_usercc_1d group by rollup(dt,Qtype,UserCC) order by dt,UserCC,Qtype;")
rows, err := conn.Query(ctx, "select max(dt) as d,UserCC,Qtype,sum(queries) as queries from by_usercc_1d where dt > now() - INTERVAL 4 DAY group by rollup(Qtype,UserCC) order by UserCC,Qtype;")
rows, err := d.conn.Query(ctx, "select max(dt) as d,UserCC,Qtype,sum(queries) as queries from by_usercc_1d where dt > now() - INTERVAL 4 DAY group by rollup(Qtype,UserCC) order by UserCC,Qtype;")
if err != nil {
slog.Error("query error", "err", err)
return nil, fmt.Errorf("database error")