cmd/ur*: Updates for 1.0

This commit is contained in:
Jakob Borg 2019-01-03 21:46:02 +01:00
parent 78ccedfeec
commit 597cee67d3
2 changed files with 11 additions and 6 deletions

View File

@ -181,7 +181,7 @@ func aggregateVersionSummary(db *sql.DB, since time.Time) (int64, error) {
WHERE
DATE_TRUNC('day', Received) > $1
AND DATE_TRUNC('day', Received) < DATE_TRUNC('day', NOW())
AND Version like 'v0.%'
AND Version like 'v_.%'
GROUP BY Day, Ver
);
`, since)
@ -199,7 +199,7 @@ func aggregateUserMovement(db *sql.DB) (int64, error) {
FROM Reports
WHERE
DATE_TRUNC('day', Received) < DATE_TRUNC('day', NOW())
AND Version like 'v0.%'
AND Version like 'v_.%'
ORDER BY Day
`)
if err != nil {
@ -285,7 +285,7 @@ func aggregatePerformance(db *sql.DB, since time.Time) (int64, error) {
WHERE
DATE_TRUNC('day', Received) > $1
AND DATE_TRUNC('day', Received) < DATE_TRUNC('day', NOW())
AND Version like 'v0.%'
AND Version like 'v_.%'
GROUP BY Day
);
`, since)
@ -315,7 +315,7 @@ func aggregateBlockStats(db *sql.DB, since time.Time) (int64, error) {
DATE_TRUNC('day', Received) > $1
AND DATE_TRUNC('day', Received) < DATE_TRUNC('day', NOW())
AND ReportVersion = 3
AND Version LIKE 'v0.%'
AND Version like 'v_.%'
AND Version NOT LIKE 'v0.14.40%'
AND Version NOT LIKE 'v0.14.39%'
AND Version NOT LIKE 'v0.14.38%'

View File

@ -29,7 +29,7 @@ import (
"unicode"
"github.com/lib/pq"
"github.com/oschwald/geoip2-golang"
geoip2 "github.com/oschwald/geoip2-golang"
)
var (
@ -816,6 +816,11 @@ func newDataHandler(db *sql.DB, w http.ResponseWriter, r *http.Request) {
}
if err := insertReport(db, rep); err != nil {
if err.Error() == `pq: duplicate key value violates unique constraint "uniqueidindex"` {
// We already have a report today for the same unique ID; drop
// this one without complaining.
return
}
log.Println("insert:", err)
if debug {
log.Printf("%#v", rep)
@ -1501,7 +1506,7 @@ func getSummary(db *sql.DB) (summary, error) {
}
// SUPER UGLY HACK to avoid having to do sorting properly
if len(ver) == 4 { // v0.x
if len(ver) == 4 && strings.HasPrefix(ver, "v0.") { // v0.x
ver = ver[:3] + "0" + ver[3:] // now v0.0x
}