Commit 7a54627d authored by Arnaud Campeas's avatar Arnaud Campeas
Browse files

timeserie: provide a helper method to compute the previous changeset id for a serie

parent 8ee39f953bc2
......@@ -56,6 +56,7 @@ def test_differential(engine, tsh):
tsh.insert(engine, ts_begin, 'ts_test', 'test')
id1 = tsh.last_id(engine, 'ts_test')
assert tsh._previous_cset(engine, 'ts_test', id1) is None
assert tsh.exists(engine, 'ts_test')
assert not tsh.exists(engine, 'this_does_not_exist')
......@@ -94,6 +95,7 @@ def test_differential(engine, tsh):
ts_slight_variation.iloc[6] = 0
tsh.insert(engine, ts_slight_variation, 'ts_test', 'celeste')
id2 = tsh.last_id(engine, 'ts_test')
assert tsh._previous_cset(engine, 'ts_test', id2) == id1
2010-01-01 0.0
......@@ -189,6 +189,13 @@ class TimeSerie(SeriesServices): = seriename
return serie
def _previous_cset(self, cn, seriename, csid):
tablename = self._serie_to_tablename(cn, seriename)
sql = ('select cset from "{}.timeserie"."{}" '
'where cset < %(csid)s '
'order by cset desc limit 1').format(self.namespace, tablename)
return cn.execute(sql, csid=csid).scalar()
def get_delta(self, cn, seriename, delta,
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment