diff --git a/backend/memory/memory.go b/backend/memory/memory.go index 429fbc9..2ce781e 100644 --- a/backend/memory/memory.go +++ b/backend/memory/memory.go @@ -125,7 +125,7 @@ func (r *Backend) GetRawData(tenant string, id string, end int64, start int64, l } // sanity check pEnd - if pEnd < pStart { + if pEnd <= pStart { pEnd += arraySize } @@ -134,7 +134,7 @@ func (r *Backend) GetRawData(tenant string, id string, end int64, start int64, l // fill data out array count := int64(0) - for i := pStart; count < limit && i <= pEnd; i++ { + for i := pEnd; count < limit && i > pStart; i-- { d := r.tenant[tenant].ts[id].data[i%arraySize] // if this is a valid point @@ -147,6 +147,14 @@ func (r *Backend) GetRawData(tenant string, id string, end int64, start int64, l } } + // order + if order == "ASC" { + for i := 0; i < len(res)/2; i++ { + j := len(res) - i - 1 + res[i], res[j] = res[j], res[i] + } + } + return res } @@ -174,7 +182,7 @@ func (r Backend) GetStatData(tenant string, id string, end int64, start int64, l pEnd := r.getPosForTimestamp(end) // sanity check pEnd - if pEnd < pStart { + if pEnd <= pStart { pEnd += arraySize } @@ -242,6 +250,14 @@ func (r Backend) GetStatData(tenant string, id string, end int64, start int64, l } } + // order + if order == "ASC" { + for i := 0; i < len(res)/2; i++ { + j := len(res) - i - 1 + res[i], res[j] = res[j], res[i] + } + } + return res } diff --git a/main.go b/main.go index 6b90fe8..98d615a 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ import ( ) // VER the server version -const VER = "0.12.7" +const VER = "0.13.1" // defaults const defaultPort = 8080 diff --git a/mohawk.spec b/mohawk.spec index 843b78c..94567f3 100644 --- a/mohawk.spec +++ b/mohawk.spec @@ -9,7 +9,7 @@ %global shortcommit %(c=%{commit}; echo ${c:0:7}) Name: %{repo} -Version: 0.12.7 +Version: 0.13.1 Release: 6%{?dist} Summary: Mock Hawkular server License: MIT