def fetch_things(t_class, since, until, batch_fn=None, *query_params, **extra_query_dict):
 from r2.lib.db.operators import asc
 if (not batch_fn):
  batch_fn = (lambda x: x)
 query_params = ([(t_class.c._date >= since), (t_class.c._date < until), (t_class.c._spam == (True, False))] + list(query_params))
 query_dict = {'sort': asc('_date'), 'limit': 100, 'data': True}
 query_dict.update(extra_query_dict)
 q = t_class._query(*query_params, **query_dict)
 orig_rules = deepcopy(q._rules)
 things = list(q)
 while things:
  things = batch_fn(things)
  for t in things:
   (yield t)
  q._rules = deepcopy(orig_rules)
  q._after(t)
  things = list(q)

def fetch_things ( t_class , since , until , batch_fn = None , * query_params , ** extra_query_dict ) : from r2 . lib . db . operators import asc if ( not batch_fn ) : batch_fn = ( lambda x : x ) query_params = ( [ ( t_class . c . _date >= since ) , ( t_class . c . _date < until ) , ( t_class . c . _spam == ( True , False ) ) ] + list ( query_params ) ) query_dict = { 'sort' : asc ( '_date' ) , 'limit' : 100 , 'data' : True } query_dict . update ( extra_query_dict ) q = t_class . _query ( * query_params , ** query_dict ) orig_rules = deepcopy ( q . _rules ) things = list ( q ) while things : things = batch_fn ( things ) for t in things : ( yield t ) q . _rules = deepcopy ( orig_rules ) q . _after ( t ) things = list ( q )
simple utility function to fetch all things of class t_class that were created from since to until .