diff --git a/cmd/mtwebmapper/players.go b/cmd/mtwebmapper/players.go index bc9485f..f62c820 100644 --- a/cmd/mtwebmapper/players.go +++ b/cmd/mtwebmapper/players.go @@ -22,7 +22,10 @@ import ( "bitbucket.org/s_l_teichmann/mtsatellite/common" ) -const sleepInterval = time.Second * 5 +const ( + sleepInterval = time.Second * 5 + sleepPG = time.Second +) var geoJSONTmpl = template.Must(template.New("geojson").Parse( `{ "type": "Feature", @@ -83,11 +86,12 @@ func (pls sortPlayersByName) Swap(i, j int) { } const selectPlayersSQL = ` -SELECT posx, posy, posz, name +SELECT posx/10.0, posy/10.0, posz/10.0, name FROM player WHERE modification_date > now() - '2m'::interval` func playersFromPostgreSQL(connS string) ([]*player, error) { + time.Sleep(sleepPG) db, err := sql.Open("pgx", connS) if err != nil { return nil, err @@ -101,7 +105,7 @@ func playersFromPostgreSQL(connS string) ([]*player, error) { var pls []*player for rows.Next() { var p player - if err := rows.Scan(&p.Y, &p.Y, &p.Z, &p.Name); err != nil { + if err := rows.Scan(&p.X, &p.Y, &p.Z, &p.Name); err != nil { return nil, err } pls = append(pls, &p)