db crate support for updating signals (#28)

This is a definite work in progress. In particular,

* there's no src/web.rs support yet so it can't be used,
* the code is surprisingly complex, and there's almost no tests so far.
  I want to at least get complete branch coverage.
* I may still go back to time_sec rather than time_90k to save RAM and
  flash.

I simplified the approach a bit from the earlier goal in design/api.md.
In particular, there's no longer the separate concept of "observation"
vs "prediction". Now the predictions are just observations that extend a
bit beyond now. They may be flushed prematurely and I'll try living with
that to avoid making things even more complex.
This commit is contained in:
Scott Lamb
2019-06-13 21:55:15 -07:00
parent d232ca55fa
commit 7dd98bb76a
8 changed files with 538 additions and 132 deletions

View File

@@ -297,7 +297,7 @@ impl ServiceInner {
fn stream_recordings(&self, req: &Request<::hyper::Body>, uuid: Uuid, type_: db::StreamType)
-> ResponseResult {
let (r, split) = {
let mut time = recording::Time(i64::min_value()) .. recording::Time(i64::max_value());
let mut time = recording::Time::min_value() .. recording::Time::max_value();
let mut split = recording::Duration(i64::max_value());
if let Some(q) = req.uri().query() {
for (key, value) in form_urlencoded::parse(q.as_bytes()) {
@@ -630,7 +630,7 @@ impl ServiceInner {
}
fn signals(&self, req: &Request<hyper::Body>) -> ResponseResult {
let mut time = recording::Time(i64::min_value()) .. recording::Time(i64::max_value());
let mut time = recording::Time::min_value() .. recording::Time::max_value();
if let Some(q) = req.uri().query() {
for (key, value) in form_urlencoded::parse(q.as_bytes()) {
let (key, value) = (key.borrow(), value.borrow());
@@ -653,7 +653,7 @@ impl ServiceInner {
signals.times_90k.push(c.when.0);
signals.signal_ids.push(c.signal);
signals.states.push(c.state);
}).map_err(internal_server_err)?;
});
serve_json(req, &signals)
}