Skip to content

Commit

Permalink
Fix InfluxDB time bug (#689)
Browse files Browse the repository at this point in the history
Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
  • Loading branch information
dborovcanin authored and drasko committed Apr 4, 2019
1 parent 4f62f89 commit e4d3b1d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion writers/influxdb/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package influxdb

import (
"errors"
"math"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -112,7 +113,9 @@ func (repo *influxRepo) savePoint(point *influxdata.Point) error {

func (repo *influxRepo) Save(msg mainflux.Message) error {
tgs, flds := repo.tagsOf(&msg), repo.fieldsOf(&msg)
t := time.Unix(int64(msg.Time), 0)

sec, dec := math.Modf(msg.Time)
t := time.Unix(int64(sec), int64(dec*(1e9)))

pt, err := influxdata.NewPoint(pointName, tgs, flds, t)
if err != nil {
Expand Down

0 comments on commit e4d3b1d

Please sign in to comment.