add a end boundary for the query

the upper limit in the query is used to avoid consuming too much memory
when generating stats with alot of queue_log after the current
period. This is what usually happens after a `xivo-stat clean_db`.

I used an arbitrary end value of 1 day over the end of the period we are
currently working on. The bounds of each call is checked in the loop
lower in the function.
parent 9d540a26
......@@ -109,6 +109,9 @@ def _get_ended_call(session, start_str, end, queue_log_event, stat_event):
pairs = []
enter_queue_event = None
higher_boundary = end + timedelta(days=1)
end_str = higher_boundary.strftime(_STR_TIME_FMT)
queue_logs = (session
.query(QueueLog.event,
QueueLog.callid,
......@@ -116,6 +119,7 @@ def _get_ended_call(session, start_str, end, queue_log_event, stat_event):
QueueLog.data3,
cast(QueueLog.time, TIMESTAMP).label('time'))
.filter(and_(QueueLog.time >= start_str,
QueueLog.time < end_str,
or_(QueueLog.event == 'ENTERQUEUE',
QueueLog.event == queue_log_event)))
.order_by(QueueLog.callid, QueueLog.time))
......
Markdown is supported
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