def _getTestRunSummary(procPath, procName, fullProcPath, request, gm): productIds = [] testIds = [] platformIds = [] ##### #Calling _getIdList() insures that we have only numbers in the #lists, this gaurds against SQL injection ##### if 'product_ids' in request.GET: productIds = DatazillaModel.getIdList(request.GET['product_ids']) if 'test_ids' in request.GET: testIds = DatazillaModel.getIdList(request.GET['test_ids']) if 'platform_ids' in request.GET: platformIds = DatazillaModel.getIdList(request.GET['platform_ids']) if not productIds: ##Set default productId## productIds = [12] jsonData = '{}' timeKey = 'days_7' timeRanges = DatazillaModel.getTimeRanges() mc = memcache.Client([settings.DATAZILLA_MEMCACHED], debug=0) if productIds and (not testIds) and (not platformIds): if len(productIds) > 1: extendList = { 'data':[], 'columns':[] } for id in productIds: key = DatazillaModel.getCacheKey(str(id), timeKey) compressedJsonData = mc.get(key) if compressedJsonData: jsonData = zlib.decompress( compressedJsonData ) data = json.loads( jsonData ) extendList['data'].extend( data['data'] ) extendList['columns'] = data['columns'] jsonData = json.dumps(extendList) else: key = DatazillaModel.getCacheKey(str(productIds[0]), timeKey) compressedJsonData = mc.get(key) if compressedJsonData: jsonData = zlib.decompress( compressedJsonData ) else: table = gm.getTestRunSummary(timeRanges[timeKey]['start'], timeRanges[timeKey]['stop'], productIds, platformIds, testIds) jsonData = json.dumps( table ) return jsonData
def graphs(request, project=""): #### #Load any signals provided in the page #### signals = [] timeRanges = DatazillaModel.getTimeRanges() for s in SIGNALS: if s in request.POST: signals.append( { 'value':urllib.unquote( request.POST[s] ), 'name':s } ) ### #Get reference data ### cacheKey = str(project) + '_reference_data' jsonData = '{}' mc = memcache.Client([settings.DATAZILLA_MEMCACHED], debug=0) compressedJsonData = mc.get(cacheKey) timeKey = 'days_30' ##reference data found in the cache: decompress## if compressedJsonData: jsonData = zlib.decompress( compressedJsonData ) else: #### #reference data has not been cached: #serialize, compress, and cache #### dm = DatazillaModel(project, 'graphs.json') refData = dm.getTestReferenceData() dm.disconnect() refData['time_ranges'] = timeRanges jsonData = json.dumps(refData) mc.set(str(project) + '_reference_data', zlib.compress( jsonData ) ) data = { 'username':request.user.username, 'time_key':timeKey, 'reference_json':jsonData, 'signals':signals } #### #Caller has provided the view parent of the signals, load in page. #This occurs when a data view is in its Pane form and is detached #to exist on it's own page. #### parentIndexKey = 'dv_parent_dview_index' if parentIndexKey in request.POST: data[parentIndexKey] = request.POST[parentIndexKey] return render_to_response('graphs.views.html', data)
def buildTestSummaries(project): gm = DatazillaModel(project, 'graphs.json') timeRanges = DatazillaModel.getTimeRanges() products = gm.getProducts() for productName in products: for tr in ['days_7', 'days_30']: table = gm.getTestRunSummary(str( timeRanges[tr]['start']), str( timeRanges[tr]['stop']), [ products[ productName ] ], [], []) jsonData = json.dumps( table ) gm.setSummaryCache( products[ productName ], tr, jsonData ) gm.disconnect()