def get_series(model, extra_field=None, source=None, **filters):
 extra = (() if (extra_field is None) else (extra_field,))
 qs = model.search().order_by('-date').filter(**filters).values_dict('date', 'count', *extra)
 if source:
  qs = qs.source(source)
 for val in qs[:365]:
  date_ = parse(val['date'][0]).date()
  rv = dict(count=val['count'][0], date=date_, end=date_)
  if source:
   rv['data'] = extract(val[source])
  elif extra_field:
   rv['data'] = extract(val[extra_field])
  (yield rv)

def get_series ( model , extra_field = None , source = None , ** filters ) : extra = ( ( ) if ( extra_field is None ) else ( extra_field , ) ) qs = model . search ( ) . order_by ( '-date' ) . filter ( ** filters ) . values_dict ( 'date' , 'count' , * extra ) if source : qs = qs . source ( source ) for val in qs [ : 365 ] : date_ = parse ( val [ 'date' ] [ 0 ] ) . date ( ) rv = dict ( count = val [ 'count' ] [ 0 ] , date = date_ , end = date_ ) if source : rv [ 'data' ] = extract ( val [ source ] ) elif extra_field : rv [ 'data' ] = extract ( val [ extra_field ] ) ( yield rv )
get series .