def get_session_stats(session):
query = session.query(func.min(Sighting.expire_timestamp),
func.max(Sighting.expire_timestamp))
if conf.REPORT_SINCE:
query = query.filter(Sighting.expire_timestamp > SINCE_TIME)
min_max_result = query.one()
length_hours = (min_max_result[1] - min_max_result[0]) // 3600
if length_hours == 0:
length_hours = 1
# Convert to datetime
return {
'start': datetime.fromtimestamp(min_max_result[0]),
'end': datetime.fromtimestamp(min_max_result[1]),
'length_hours': length_hours
}
评论列表
文章目录