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

tsio/insertion_dates: provide an accessor to get them all

parent 9765893873c1
......@@ -775,6 +775,14 @@ insertion_date value_date
tsc = tsh.get_history(engine, 'no-such-series')
assert tsc is None
idates = tsh.insertion_dates(engine, 'smallserie')
assert idates == [
pd.Timestamp('2017-02-01 00:00:00+0000', tz='UTC'),
pd.Timestamp('2017-02-02 00:00:00+0000', tz='UTC'),
pd.Timestamp('2017-02-03 00:00:00+0000', tz='UTC')
]
def test_history_delta(engine, tsh):
for d in range(1, 3):
......
......@@ -286,6 +286,21 @@ class TimeSerie(SeriesServices):
cn.execute(sql).scalar()
).astimezone('UTC')
def insertion_dates(self, cn, seriename):
cset = self.schema.changeset
tstable = self._get_ts_table(cn, seriename)
sql = select(
[cset.c.insertion_date]
).where(
tstable.c.cset == cset.c.id
).order_by(
cset.c.id
)
return [
pd.Timestamp(idate).astimezone('UTC')
for idate, in cn.execute(sql).fetchall()
]
def last_id(self, cn, seriename):
snapshot = Snapshot(cn, self, seriename)
return snapshot.last_id()
......
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