Fix #500. Support `y` suffix in query time durations

pull/505/head
John Shahid 2014-05-05 14:50:13 -04:00
parent 29c55c1854
commit d0269a3516
3 changed files with 5 additions and 1 deletions

View File

@ -2,6 +2,7 @@
### Bugfixes
- [Issue #500](https://github.com/influxdb/influxdb/issues/500). Support `y` sufix in time durations
- [Issue #501](https://github.com/influxdb/influxdb/issues/501). Writes with invalid payload should be rejected
## v0.6.0 [2014-05-02]

View File

@ -37,6 +37,8 @@ func ParseTimeDuration(value string) (int64, error) {
return int64(parsedFloat * 24 * float64(time.Hour)), nil
case 'w':
return int64(parsedFloat * 7 * 24 * float64(time.Hour)), nil
case 'y':
return int64(parsedFloat * 365 * 24 * float64(time.Hour)), nil
}
lastChar := value[len(value)-1]

View File

@ -2,9 +2,9 @@ package parser
import (
"fmt"
. "launchpad.net/gocheck"
"testing"
"time"
. "launchpad.net/gocheck"
)
// Hook up gocheck into the gotest runner.
@ -419,6 +419,7 @@ func (self *QueryParserSuite) TestTimeWithNegativeEndTime(c *C) {
func (self *QueryParserSuite) TestParseSelectWithTimeCondition(c *C) {
queries := map[string]time.Time{
"select value, time from t where time > now() - 1d and time < now() - 1m;": time.Now().Add(-time.Minute).Round(time.Minute).UTC(),
"select value, time from t where time > now() - 1d and time < now() - 1y;": time.Now().Add(-365 * 24 * time.Hour).Round(time.Minute).UTC(),
"select value, time from t where time > now() - 1d and time < now();": time.Now().Round(time.Minute).UTC(),
}
for query, expected := range queries {