Skip to content

Commit 071cc52

Browse files
committed
Make days to query configurable
1 parent 88f6891 commit 071cc52

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tilequeue/command.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,19 +965,23 @@ def tilequeue_prune_tiles_of_interest(cfg, peripherals):
965965
assert redshift_uri, ("A redshift connection URI must "
966966
"be present in the config yaml")
967967

968+
redshift_days_to_query = cfg.yml.get('redshift_days')
969+
assert redshift_days_to_query, ("Number of days to query "
970+
"redshift is not specified")
971+
968972
tiles_recently_requested = set()
969973
with psycopg2.connect(redshift_uri) as conn:
970974
with conn.cursor() as cur:
971975
cur.execute("""
972976
select x, y, z
973977
from tile_traffic_v4
974-
where (date >= dateadd(day, -30, current_date))
978+
where (date >= dateadd(day, -{days}, current_date))
975979
and (z between 0 and 16)
976980
and (x between 0 and pow(2,z)-1)
977981
and (y between 0 and pow(2,z)-1)
978982
group by z, x, y
979983
order by z, x, y
980-
);""")
984+
);""".format(days=redshift_days_to_query))
981985
n_trr = cur.rowcount
982986
for (x, y, z) in cur:
983987
coord = create_coord(x, y, z)

0 commit comments

Comments
 (0)