foglamp / FogLAMP

An open source platform for the Internet of Things, it acts as an edge gateway between sensor devices and cloud storage systems
http://foglamp.readthedocs.io/
Apache License 2.0
70 stars 42 forks source link

FOGL-3516: Add sub-second granularity to time bucket size #1799

Closed pintomax closed 4 years ago

pintomax commented 4 years ago

FOGL-3516: use julianday instaead of strftime

pintomax commented 4 years ago

Examples: 50 ms curl -s 'localhost:8081/foglamp/asset/sinusoid/bucket/0.05?length=16000&start=1576244444'| jq

 {
    "asset_code": "sinusoid",
    "timestamp": "2019-12-13 14:58:24.372467",
    "reading": {
      "sinusoid": {
        "min": 0.743144825,
        "max": 0.951056516,
        "average": 0.8565578394,
        "count": 5,
        "sum": 4.282789197
      }
    }
  },
  {
    "asset_code": "sinusoid",
    "timestamp": "2019-12-13 14:58:24.322500",
    "reading": {
      "sinusoid": {
        "min": 0.309016994,
        "max": 0.669130606,
        "average": 0.494533899,
        "count": 5,
        "sum": 2.472669495
      }
    }
  },
  {
    "asset_code": "sinusoid",
    "timestamp": "2019-12-13 14:58:24.272467",
    "reading": {
      "sinusoid": {
        "min": 0,
        "max": 0.207911691,
        "average": 0.104146718,
        "count": 3,
        "sum": 0.312440154
      }
    }
  }

500 ms

curl -s localhost:8081/foglamp/asset/sinusoid/bucket/0.5?length=16000| jq

  {
    "asset_code": "sinusoid",
    "timestamp": "2019-12-13 14:58:38.745906",
    "reading": {
      "sinusoid": {
        "min": -1,
        "max": 0.669130606,
        "average": -0.382306582609756,
        "count": 41,
        "sum": -15.674569887
      }
    }
  },
  {
    "asset_code": "sinusoid",
    "timestamp": "2019-12-13 14:58:38.249764",
    "reading": {
      "sinusoid": {
        "min": -1,
        "max": 1,
        "average": 0.200455028428571,
        "count": 42,
        "sum": 8.419111194
      }
    }
  }
pintomax commented 4 years ago

NOTE: Float value is only passed to asset_datapoints_with_bucket_size()

mshariq-nerd commented 4 years ago
http://localhost:8081/foglamp/asset/sinusoid/bucket/1?length=600
Response:
400 'NoneType' object is not subscriptable