def make_history_query(cls, interval):
 time_points = get_time_points(interval)
 q = Session.query(cls).filter(cls.date.in_(time_points))
 if hasattr(cls, 'interval'):
  q = q.filter((cls.interval == interval))
 q = q.order_by(desc(cls.date))
 return (time_points, q)

def make_history_query ( cls , interval ) : time_points = get_time_points ( interval ) q = Session . query ( cls ) . filter ( cls . date . in_ ( time_points ) ) if hasattr ( cls , 'interval' ) : q = q . filter ( ( cls . interval == interval ) ) q = q . order_by ( desc ( cls . date ) ) return ( time_points , q )
build a generic query showing the history of a given aggregate .