Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[influxdb-retriever] query by period #1916

Closed
betefaber opened this issue Dec 22, 2020 · 1 comment
Closed

[influxdb-retriever] query by period #1916

betefaber opened this issue Dec 22, 2020 · 1 comment
Assignees
Labels

Comments

@betefaber
Copy link

betefaber commented Dec 22, 2020

  • using date-time in the format 2020-12-18T19:50:00.000Z
curl -X GET "${DOJOT_HOST}/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19:50:00.000Z" -H "Authorization: Bearer ${JWT}"  -H 'Content-Type:application/json' 2>/dev/null | jq
{
  "error": "Parameter 'dateFrom' must be url encoded. It's value may not contain reserved characters."
}
influxdb-retriever_1          | 2020-12-22T15:06:55.264Z -- influxdb-retriever:express/interceptors/CustomPaginator -- debug: CustomPaginator2: req.query={ dateFrom: '2020-12-18T18:58:29.311Z', page: 1, limit: 256 }
influxdb-retriever_1          | 2020-12-22T15:06:55.265Z -- influxdb-retriever:express -- debug: Bad Request: Parameter 'dateFrom' must be url encoded. It's value may not contain reserved characters.
influxdb-retriever_1          |     at RequestParameterMutator.validateReservedCharacters (/opt/influxdb-retriever/node_modules/express-openapi-validator/dist/middlewares/parsers/req.parameter.mutator.js:230:23)
influxdb-retriever_1          |     at /opt/influxdb-retriever/node_modules/express-openapi-validator/dist/middlewares/parsers/req.parameter.mutator.js:49:22
influxdb-retriever_1          |     at Array.forEach (<anonymous>)
influxdb-retriever_1          |     at RequestParameterMutator.modifyRequest (/opt/influxdb-retriever/node_modules/express-openapi-validator/dist/middlewares/parsers/req.parameter.mutator.js:41:28)
influxdb-retriever_1          |     at Object.GET-/tss/v1/devices/:deviceId/attrs/:attr/data-application/json (/opt/influxdb-retriever/node_modules/express-openapi-validator/dist/middlewares/openapi.request.validator.js:77:21)
influxdb-retriever_1          |     at RequestValidator.validate (/opt/influxdb-retriever/node_modules/express-openapi-validator/dist/middlewares/openapi.request.validator.js:53:41)
influxdb-retriever_1          |     at /opt/influxdb-retriever/node_modules/express-openapi-validator/dist/openapi.validator.js:207:53
influxdb-retriever_1          |     at /opt/influxdb-retriever/node_modules/express-openapi-validator/dist/openapi.validator.js:142:28
influxdb-retriever_1          |     at runMicrotasks (<anonymous>)
influxdb-retriever_1          |     at processTicksAndRejections (internal/process/task_queues.js:97:5) {
influxdb-retriever_1          |   status: 400,
influxdb-retriever_1          |   path: '.query.dateFrom',
influxdb-retriever_1          |   errors: [
influxdb-retriever_1          |     {
influxdb-retriever_1          |       path: '.query.dateFrom',
influxdb-retriever_1          |       message: "Parameter 'dateFrom' must be url encoded. It's value may not contain reserved characters."
influxdb-retriever_1          |     }
influxdb-retriever_1          |   ]
influxdb-retriever_1          | }

  • The command is executed if date-time is in the format 2020-12-18T19%3A50%3A00.000Z
efaber@mcity75:~$ curl -X GET "${DOJOT_HOST}/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19%3A50%3A00.000Z" -H "Authorization: Bearer ${JWT}"  -H 'Content-Type:application/json' 2>/dev/null | jq
{
  "data": [
    {
      "ts": "2020-12-18T19:55:16.462Z",
      "value": 10
    },
    {
      "ts": "2020-12-18T19:55:15.445Z",
      "value": 6
    },
    {
      "ts": "2020-12-18T19:55:14.427Z",
      "value": 5
    }
  ],
  "paging": {
    "previous": null,
    "current": {
      "number": 1,
      "url": "/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19%3A50%3A00.000Z&page=1&limit=256&order=desc&dateTo=2020-12-22T15%3A44%3A03.750Z"
    },
    "next": null
  }
}

Version: 0.5.1-rc.1
Environment: docker-compose
Operating system: Ubuntu 20.04

@betefaber
Copy link
Author

Fixed in v0.5.1-rc.2.

  • allowReserved: true
curl -X GET "${DOJOT_HOST}/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19:50:00.000Z" -H "Authorization: Bearer ${JWT}"  -H 'Content-Type:application/json' 2>/dev/null | jq
{
  "data": [
    {
      "ts": "2020-12-18T19:55:16.462Z",
      "value": 10
    },
    {
      "ts": "2020-12-18T19:55:15.445Z",
      "value": 6
    },
    {
      "ts": "2020-12-18T19:55:14.427Z",
      "value": 5
    }
  ],
  "paging": {
    "previous": null,
    "current": {
      "number": 1,
      "url": "/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19%3A50%3A00.000Z&page=1&limit=256&order=desc&dateTo=2020-12-23T14%3A46%3A51.685Z"
    },
    "next": null
  }
}
  • allowReserved: false
curl -X GET "${DOJOT_HOST}/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19%3A50%3A00.000Z" -H "Authorization: Bearer ${JWT}"  -H 'Content-Type:application/json' 2>/dev/null | jq
{
  "data": [
    {
      "ts": "2020-12-18T19:55:16.462Z",
      "value": 10
    },
    {
      "ts": "2020-12-18T19:55:15.445Z",
      "value": 6
    },
    {
      "ts": "2020-12-18T19:55:14.427Z",
      "value": 5
    }
  ],
  "paging": {
    "previous": null,
    "current": {
      "number": 1,
      "url": "/tss/v1/devices/b008c9/attrs/chuva/data?dateFrom=2020-12-18T19%3A50%3A00.000Z&page=1&limit=256&order=desc&dateTo=2020-12-23T14%3A44%3A02.866Z"
    },
    "next": null
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants