Skip to content

Commit

Permalink
fix #2599: make units consistent with write
Browse files Browse the repository at this point in the history
@neonstalwart, thanks for the suggestion.
  • Loading branch information
dgnorton committed May 28, 2015
1 parent dab1224 commit d94bb93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 14 additions & 2 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,13 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
name: "single point with timestamp in nanosecond epoch",
query: `SELECT * FROM "%DB%"."%RP%".cpu`,
expected: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[[1425085416703820946,100]]}]}]}`,
urlValues: url.Values{"epoch": []string{"ns"}},
urlValues: url.Values{"epoch": []string{"n"}},
},
{
name: "single point with timestamp in microsecond epoch",
query: `SELECT * FROM "%DB%"."%RP%".cpu`,
expected: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[[1425085416703820,100]]}]}]}`,
urlValues: url.Values{"epoch": []string{"us"}},
urlValues: url.Values{"epoch": []string{"u"}},
},
{
name: "single point with timestamp in millisecond epoch",
Expand All @@ -478,6 +478,18 @@ func runTestsData(t *testing.T, testName string, nodes Cluster, database, retent
expected: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[[1425085416,100]]}]}]}`,
urlValues: url.Values{"epoch": []string{"s"}},
},
{
name: "single point with timestamp in minute epoch",
query: `SELECT * FROM "%DB%"."%RP%".cpu`,
expected: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[[23751423,100]]}]}]}`,
urlValues: url.Values{"epoch": []string{"m"}},
},
{
name: "single point with timestamp in hour epoch",
query: `SELECT * FROM "%DB%"."%RP%".cpu`,
expected: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[[395857,100]]}]}]}`,
urlValues: url.Values{"epoch": []string{"h"}},
},

// Selecting tags
{
Expand Down
6 changes: 5 additions & 1 deletion httpd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,16 @@ func convertToEpoch(r *influxdb.Result, epoch string) {
divisor := int64(1)

switch epoch {
case "us":
case "u":
divisor = 1000
case "ms":
divisor = 1000000
case "s":
divisor = 1000000000
case "m":
divisor = 60000000000
case "h":
divisor = 3600000000000
}

for _, s := range r.Series {
Expand Down

0 comments on commit d94bb93

Please sign in to comment.