mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 01:04:14 +00:00
cmd/ursrv: Fix broken block transfer chart
This commit is contained in:
parent
dc6d695c00
commit
5a50de1154
@ -119,13 +119,13 @@ func setupDB(db *sql.DB) error {
|
|||||||
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS BlockStats (
|
_, err = db.Exec(`CREATE TABLE IF NOT EXISTS BlockStats (
|
||||||
Day TIMESTAMP NOT NULL,
|
Day TIMESTAMP NOT NULL,
|
||||||
Reports INTEGER NOT NULL,
|
Reports INTEGER NOT NULL,
|
||||||
Total INTEGER NOT NULL,
|
Total BIGINT NOT NULL,
|
||||||
Renamed INTEGER NOT NULL,
|
Renamed BIGINT NOT NULL,
|
||||||
Reused INTEGER NOT NULL,
|
Reused BIGINT NOT NULL,
|
||||||
Pulled INTEGER NOT NULL,
|
Pulled BIGINT NOT NULL,
|
||||||
CopyOrigin INTEGER NOT NULL,
|
CopyOrigin BIGINT NOT NULL,
|
||||||
CopyOriginShifted INTEGER NOT NULL,
|
CopyOriginShifted BIGINT NOT NULL,
|
||||||
CopyElsewhere INTEGER NOT NULL
|
CopyElsewhere BIGINT NOT NULL
|
||||||
)`)
|
)`)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -306,13 +306,13 @@ func aggregateBlockStats(db *sql.DB, since time.Time) (int64, error) {
|
|||||||
SELECT
|
SELECT
|
||||||
DATE_TRUNC('day', Received) AS Day,
|
DATE_TRUNC('day', Received) AS Day,
|
||||||
COUNT(1) As Reports,
|
COUNT(1) As Reports,
|
||||||
SUM((Report->'blockStats'->>'total')::numeric) AS Total,
|
SUM((Report->'blockStats'->>'total')::numeric)::bigint AS Total,
|
||||||
SUM((Report->'blockStats'->>'renamed')::numeric) AS Renamed,
|
SUM((Report->'blockStats'->>'renamed')::numeric)::bigint AS Renamed,
|
||||||
SUM((Report->'blockStats'->>'reused')::numeric) AS Reused,
|
SUM((Report->'blockStats'->>'reused')::numeric)::bigint AS Reused,
|
||||||
SUM((Report->'blockStats'->>'pulled')::numeric) AS Pulled,
|
SUM((Report->'blockStats'->>'pulled')::numeric)::bigint AS Pulled,
|
||||||
SUM((Report->'blockStats'->>'copyOrigin')::numeric) AS CopyOrigin,
|
SUM((Report->'blockStats'->>'copyOrigin')::numeric)::bigint AS CopyOrigin,
|
||||||
SUM((Report->'blockStats'->>'copyOriginShifted')::numeric) AS CopyOriginShifted,
|
SUM((Report->'blockStats'->>'copyOriginShifted')::numeric)::bigint AS CopyOriginShifted,
|
||||||
SUM((Report->'blockStats'->>'copyElsewhere')::numeric) AS CopyElsewhere
|
SUM((Report->'blockStats'->>'copyElsewhere')::numeric)::bigint AS CopyElsewhere
|
||||||
FROM ReportsJson
|
FROM ReportsJson
|
||||||
WHERE
|
WHERE
|
||||||
Received > $1
|
Received > $1
|
||||||
|
@ -1133,6 +1133,10 @@ func getBlockStats(db *sql.DB) ([][]interface{}, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Legacy bad data on certain days
|
||||||
|
if reports <= 0 || pulled < 0 || renamed < 0 || reused < 0 || copyOrigin < 0 || copyOriginShifted < 0 || copyElsewhere < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
row := []interface{}{
|
row := []interface{}{
|
||||||
day.Format("2006-01-02"),
|
day.Format("2006-01-02"),
|
||||||
reports,
|
reports,
|
||||||
|
Loading…
Reference in New Issue
Block a user