Commit fddf4490 authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

tsio: a public method to retrieve the latest insertion date

parent f4f1a1d6f921
......@@ -322,6 +322,7 @@ def test_revision_date(engine):
index=pd.date_range(start=datetime(2010, 1, 4),
freq='D', periods=4), name='truc')
tso.insert(engine, ts, 'ts_through_time', 'test')
assert mock_date.now.return_value == tso.latest_insertion_date(engine, 'ts_through_time')
with patch('tshistory.tsio.datetime') as mock_date:
mock_date.now.return_value = datetime(2015, 1, 2, 15, 43, 23)
......@@ -330,6 +331,7 @@ def test_revision_date(engine):
index=pd.date_range(start=datetime(2010, 1, 4),
freq='D', periods=4), name='truc')
tso.insert(engine, ts, 'ts_through_time', 'test')
assert mock_date.now.return_value == tso.latest_insertion_date(engine, 'ts_through_time')
with patch('tshistory.tsio.datetime') as mock_date:
mock_date.now.return_value = datetime(2015, 1, 3, 15, 43, 23)
......@@ -338,6 +340,7 @@ def test_revision_date(engine):
index=pd.date_range(start=datetime(2010, 1, 4),
freq='D', periods=4), name='truc')
tso.insert(engine, ts, 'ts_through_time', 'test')
assert mock_date.now.return_value == tso.latest_insertion_date(engine, 'ts_through_time')
ts = tso.get(engine, 'ts_through_time')
......
......@@ -173,6 +173,13 @@ class TimeSerie(object):
cnx.execute(sql)
return True
def latest_insertion_date(self, cnx, name):
cset = schema.changeset
tstable = self._get_ts_table(cnx, name)
sql = select([func.max(cset.c.insertion_date)]
).where(tstable.c.csid == cset.c.id)
return cnx.execute(sql).scalar()
# /API
# Helpers
......
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