This commit is contained in:
Aditya Ujeniya 2024-09-17 10:49:32 +02:00
parent 545c176974
commit 4ac6cef01f
7 changed files with 26 additions and 8 deletions

2
.gitignore vendored
View File

@ -19,6 +19,8 @@
/var /var
/configs /configs
sample.txt
migrateTimestamps.pl migrateTimestamps.pl
test_ccms_api.sh test_ccms_api.sh
test_ccms_free_api.sh

View File

@ -75,7 +75,7 @@
} }
}, },
"/free/": { "/free/": {
"get": { "post": {
"security": [ "security": [
{ {
"ApiKeyAuth": [] "ApiKeyAuth": []
@ -273,6 +273,9 @@
"min": { "min": {
"type": "number" "type": "number"
}, },
"resolution": {
"type": "integer"
},
"to": { "to": {
"type": "integer" "type": "integer"
} }
@ -290,6 +293,9 @@
"metric": { "metric": {
"type": "string" "type": "string"
}, },
"resolution": {
"type": "integer"
},
"scale-by": { "scale-by": {
"type": "number" "type": "number"
}, },

View File

@ -16,6 +16,8 @@ definitions:
type: number type: number
min: min:
type: number type: number
resolution:
type: integer
to: to:
type: integer type: integer
type: object type: object
@ -27,6 +29,8 @@ definitions:
type: string type: string
metric: metric:
type: string type: string
resolution:
type: integer
scale-by: scale-by:
type: number type: number
subtype: subtype:
@ -137,7 +141,7 @@ paths:
tags: tags:
- debug - debug
/free/: /free/:
get: post:
parameters: parameters:
- description: up to timestamp - description: up to timestamp
in: query in: query

View File

@ -136,7 +136,7 @@ func (data *ApiMetricData) PadDataWithNull(ms *memorystore.MemoryStore, from, to
// @failure 403 {object} api.ErrorResponse "Forbidden" // @failure 403 {object} api.ErrorResponse "Forbidden"
// @failure 500 {object} api.ErrorResponse "Internal Server Error" // @failure 500 {object} api.ErrorResponse "Internal Server Error"
// @security ApiKeyAuth // @security ApiKeyAuth
// @router /free/ [get] // @router /free/ [post]
func handleFree(rw http.ResponseWriter, r *http.Request) { func handleFree(rw http.ResponseWriter, r *http.Request) {
rawTo := r.URL.Query().Get("to") rawTo := r.URL.Query().Get("to")
if rawTo == "" { if rawTo == "" {

View File

@ -81,7 +81,7 @@ const docTemplate = `{
} }
}, },
"/free/": { "/free/": {
"get": { "post": {
"security": [ "security": [
{ {
"ApiKeyAuth": [] "ApiKeyAuth": []
@ -279,6 +279,9 @@ const docTemplate = `{
"min": { "min": {
"type": "number" "type": "number"
}, },
"resolution": {
"type": "integer"
},
"to": { "to": {
"type": "integer" "type": "integer"
} }
@ -296,6 +299,9 @@ const docTemplate = `{
"metric": { "metric": {
"type": "string" "type": "string"
}, },
"resolution": {
"type": "integer"
},
"scale-by": { "scale-by": {
"type": "number" "type": "number"
}, },

View File

@ -255,7 +255,8 @@ func decodeLine(dec *lineprotocol.Decoder,
if len(subTypeBuf) == 0 { if len(subTypeBuf) == 0 {
subTypeBuf = append(subTypeBuf, val...) subTypeBuf = append(subTypeBuf, val...)
} else { } else {
subTypeBuf = reorder(typeBuf, val) subTypeBuf = reorder(subTypeBuf, val)
// subTypeBuf = reorder(typeBuf, val)
} }
case "stype-id": case "stype-id":
subTypeBuf = append(subTypeBuf, val...) subTypeBuf = append(subTypeBuf, val...)
@ -308,7 +309,7 @@ func decodeLine(dec *lineprotocol.Decoder,
} }
if t, err = dec.Time(lineprotocol.Second, t); err != nil { if t, err = dec.Time(lineprotocol.Second, t); err != nil {
return err return fmt.Errorf("timestamp : %#v with error : %#v", lineprotocol.Second, err.Error())
} }
if err := ms.WriteToLevel(lvl, selector, t.Unix(), []memorystore.Metric{metric}); err != nil { if err := ms.WriteToLevel(lvl, selector, t.Unix(), []memorystore.Metric{metric}); err != nil {

View File

@ -42,7 +42,7 @@ func LargestTriangleThreeBucket(data []util.Float, old_frequency int64, new_freq
} }
if new_frequency%old_frequency != 0 { if new_frequency%old_frequency != 0 {
return nil, 0, errors.New(fmt.Sprintf("new sampling frequency : %d should be multiple of the old frequency : %d", new_frequency, old_frequency)) return nil, 0, fmt.Errorf("new sampling frequency : %d should be multiple of the old frequency : %d", new_frequency, old_frequency)
} }
var step int = int(new_frequency / old_frequency) var step int = int(new_frequency / old_frequency)
@ -100,7 +100,6 @@ func LargestTriangleThreeBucket(data []util.Float, old_frequency int64, new_freq
} }
if math.IsNaN(float64(avgPointY)) { if math.IsNaN(float64(avgPointY)) {
flag_ = 1 flag_ = 1
} }
} }