Skip to content

Commit

Permalink
Use server time instead of gateway reported time in stats (#440)
Browse files Browse the repository at this point in the history
Closes #408.
  • Loading branch information
mmrein committed Mar 16, 2020
1 parent 5e39b3a commit dfd3b31
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions internal/api/as/as.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"math"
"net"
"time"

"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty"
"github.com/jmoiron/sqlx"
"github.com/lib/pq/hstore"
Expand Down Expand Up @@ -462,12 +462,9 @@ func (a *ApplicationServerAPI) HandleGatewayStats(ctx context.Context, req *as.H
var gatewayID lorawan.EUI64
copy(gatewayID[:], req.GatewayId)

ts, err := ptypes.Timestamp(req.Time)
if err != nil {
return nil, helpers.ErrToRPCError(errors.Wrap(err, "time error"))
}

err = storage.Transaction(func(tx sqlx.Ext) error {
ts := time.Now()

err := storage.Transaction(func(tx sqlx.Ext) error {
gw, err := storage.GetGateway(ctx, tx, gatewayID, true)
if err != nil {
return helpers.ErrToRPCError(errors.Wrap(err, "get gateway error"))
Expand Down

0 comments on commit dfd3b31

Please sign in to comment.