#NEWLINE# def _get_data_case( self , params , filters ) : #NEWLINE# #INDENT# MAX_RESULTS = 200 #NEWLINE# _get = self . request . GET . copy ( ) #NEWLINE# _get [ 'iDisplayStart' ] = '0' #NEWLINE# _get [ 'iDisplayLength' ] = str ( MAX_RESULTS ) #NEWLINE# self . request . GET = _get #NEWLINE# source = CaseListReport ( self . request , domain = self . domain ) #NEWLINE# total_count = source . es_results [ 'hits' ] [ 'total' ] #NEWLINE# if ( total_count > MAX_RESULTS ) : #NEWLINE# #INDENT# ( yield { #NEWLINE# #INDENT# '_meta' : { #NEWLINE# #INDENT# 'total_rows' : total_count , #NEWLINE# 'capped_rows' : MAX_RESULTS , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# for data in source . get_data ( ) : #NEWLINE# #INDENT# case = CommCareCase . wrap ( data [ '_case' ] ) . to_api_json ( ) #NEWLINE# del data [ '_case' ] #NEWLINE# data [ 'num_forms' ] = len ( case [ 'xform_ids' ] ) #NEWLINE# standard_props = ( 'case_name' , 'case_type' , 'date_opened' , 'external_id' , 'owner_id' ) #NEWLINE# data . update ( ( ( ( 'prop_%s' % k ) , v ) for ( k , v ) in case [ 'properties' ] . iteritems ( ) if ( k not in standard_props ) ) ) #NEWLINE# GEO_DEFAULT = 'gps' #NEWLINE# geo = None #NEWLINE# geo_directive = params [ 'geo_fetch' ] . get ( data [ 'case_type' ] , GEO_DEFAULT ) #NEWLINE# if geo_directive . startswith ( 'link:' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( geo_directive == '_random' ) : #NEWLINE# #INDENT# import random #NEWLINE# import math #NEWLINE# geo = ( '%s %s' % ( math . degrees ( math . asin ( random . uniform ( ( - 1 ) , 1 ) ) ) , random . uniform ( ( - 180 ) , 180 ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if geo_directive : #NEWLINE# #INDENT# geo = data . get ( ( 'prop_%s' % geo_directive ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if geo : #NEWLINE# #INDENT# data [ 'geo' ] = geo #NEWLINE# ( yield data )