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

insertion_dates: allow to restrict the range

parent ef44e07e5302
......@@ -811,6 +811,14 @@ insertion_date value_date
pd.Timestamp('2017-02-02 00:00:00+0000', tz='UTC'),
pd.Timestamp('2017-02-03 00:00:00+0000', tz='UTC')
]
idates = tsh.insertion_dates(
engine, 'smallserie',
fromdate=utcdt(2017, 2, 2),
todate=utcdt(2017, 2, 2)
)
assert idates == [
pd.Timestamp('2017-02-02 00:00:00+0000', tz='UTC'),
]
......
......@@ -291,7 +291,8 @@ class TimeSerie(SeriesServices):
cn.execute(sql).scalar()
).astimezone('UTC')
def insertion_dates(self, cn, seriename):
def insertion_dates(self, cn, seriename,
fromdate=None, todate=None):
cset = self.schema.changeset
tstable = self._get_ts_table(cn, seriename)
sql = select(
......@@ -301,6 +302,12 @@ class TimeSerie(SeriesServices):
).order_by(
cset.c.id
)
if fromdate:
sql = sql.where(cset.c.insertion_date >= fromdate)
if todate:
sql = sql.where(cset.c.insertion_date <= todate)
return [
pd.Timestamp(idate).astimezone('UTC')
for idate, in cn.execute(sql).fetchall()
......
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