Code

store: Fixed JSON-serialization of time-series data.
authorSebastian Harl <sh@tokkee.org>
Thu, 21 Aug 2014 03:12:58 +0000 (20:12 -0700)
committerSebastian Harl <sh@tokkee.org>
Thu, 21 Aug 2014 03:12:58 +0000 (20:12 -0700)
Typos caused the end-time and all values to be treated incorrectly.

src/core/store.c

index c778c52d7dd4a234890b381bea8fb5434a4bab0a..3bc111496ab9a64f5c79a517ccec41e8298f24f2 100644 (file)
@@ -551,7 +551,7 @@ ts_tojson(sdb_timeseries_t *ts, sdb_strbuf_t *buf)
                snprintf(start_str, sizeof(start_str), "<error>");
        start_str[sizeof(start_str) - 1] = '\0';
        if (! sdb_strftime(end_str, sizeof(end_str),
-                               "%F %T %z", ts->start))
+                               "%F %T %z", ts->end))
                snprintf(end_str, sizeof(end_str), "<error>");
        end_str[sizeof(end_str) - 1] = '\0';
 
@@ -571,7 +571,7 @@ ts_tojson(sdb_timeseries_t *ts, sdb_strbuf_t *buf)
                        time_str[sizeof(time_str) - 1] = '\0';
 
                        sdb_strbuf_append(buf, "{\"timestamp\": \"%s\", "
-                                       "\"value\": \"%s\"}", time_str, ts->data[i][j].value);
+                                       "\"value\": \"%f\"}", time_str, ts->data[i][j].value);
 
                        if (j < ts->data_len - 1)
                                sdb_strbuf_append(buf, ",");