def graphs(request, project=""): #### #Load any signals provided in the page #### signals = [] time_ranges = utils.get_time_ranges() for s in SIGNALS: if s in request.POST: signals.append( { 'value':urllib.unquote( request.POST[s] ), 'name':s } ) ### #Get reference data ### ptm = PerformanceTestModel(project) json_data = ptm.get_test_reference_data() ptm.disconnect() time_key = 'days_30' data = { 'time_key':time_key, 'reference_json':json_data, '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. #### parent_index_key = 'dv_parent_dview_index' if parent_index_key in request.POST: data[parent_index_key] = request.POST[parent_index_key] return render_to_response('graphs.views.html', data)
def graphs(request, project=""): #### #Load any signals provided in the page #### signals = [] timeRanges = utils.get_time_ranges() 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) refData = dm.getTestReferenceData() dm.disconnect() refData['time_ranges'] = timeRanges jsonData = json.dumps(refData) mc.set(str(project) + '_reference_data', zlib.compress( jsonData ) ) data = { '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 _get_test_run_summary(project, method, request, dm): product_ids = [] test_ids = [] platform_ids = [] ##### #Calling get_id_list() insures that we have only numbers in the #lists, this gaurds against SQL injection ##### if 'product_ids' in request.GET: product_ids = utils.get_id_list(request.GET['product_ids']) if 'test_ids' in request.GET: test_ids = utils.get_id_list(request.GET['test_ids']) if 'platform_ids' in request.GET: platform_ids = utils.get_id_list(request.GET['platform_ids']) time_key = 'days_30' time_ranges = utils.get_time_ranges() if 'tkey' in request.GET: time_key = request.GET['tkey'] if not product_ids: ##Default to id 1 product_ids = [1] ##Set default product_id pck = dm.get_project_cache_key('default_product') default_products = cache.get(pck) default_products = dm.get_default_products() ##If we have one use it if default_products: product_ids = map( int, default_products.split(',') ) json_data = '{}' table = dm.get_test_run_summary(time_ranges[time_key]['start'], time_ranges[time_key]['stop'], product_ids, platform_ids, test_ids) json_data = json.dumps( table ) return json_data
def _get_test_run_summary(project, method, request, dm): product_ids = [] test_ids = [] platform_ids = [] ##### #Calling get_id_list() insures that we have only numbers in the #lists, this gaurds against SQL injection ##### if 'product_ids' in request.GET: product_ids = utils.get_id_list(request.GET['product_ids']) if 'test_ids' in request.GET: test_ids = utils.get_id_list(request.GET['test_ids']) if 'platform_ids' in request.GET: platform_ids = utils.get_id_list(request.GET['platform_ids']) time_key = 'days_30' time_ranges = utils.get_time_ranges() if 'tkey' in request.GET: time_key = request.GET['tkey'] if not product_ids: ##Default to id 1 product_ids = [1] ##Set default product_id pck = dm.get_project_cache_key('default_product') default_products = cache.get(pck) default_products = dm.get_default_products() ##If we have one use it if default_products: product_ids = map(int, default_products.split(',')) json_data = '{}' table = dm.get_test_run_summary(time_ranges[time_key]['start'], time_ranges[time_key]['stop'], product_ids, platform_ids, test_ids) json_data = json.dumps(table) return json_data
def build_test_summaries(project): ptm = PerformanceTestModel(project) time_ranges = utils.get_time_ranges() products = ptm.get_products() for product_name in products: for tr in ['days_7', 'days_30']: table = ptm.get_test_run_summary(str(time_ranges[tr]['start']), str(time_ranges[tr]['stop']), [products[product_name]], [], []) json_data = json.dumps(table) ptm.set_summary_cache(products[product_name], tr, json_data) ptm.disconnect()
def graphs(request, project=""): #### #Load any signals provided in the page #### signals = [] time_ranges = utils.get_time_ranges() for s in SIGNALS: if s in request.POST: signals.append({ 'value': urllib.unquote(request.POST[s]), 'name': s }) ### #Get reference data ### ptm = PerformanceTestModel(project) json_data = ptm.get_test_reference_data() ptm.disconnect() time_key = 'days_30' data = { 'time_key': time_key, 'reference_json': json_data, '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. #### parent_index_key = 'dv_parent_dview_index' if parent_index_key in request.POST: data[parent_index_key] = request.POST[parent_index_key] return render_to_response('graphs.views.html', data)
def build_test_summaries(project): ptm = PerformanceTestModel(project) time_ranges = utils.get_time_ranges() products = ptm.get_products() for product_name in products: for tr in ['days_7', 'days_30']: table = ptm.get_test_run_summary(str( time_ranges[tr]['start']), str( time_ranges[tr]['stop']), [ products[ product_name ] ], [], []) json_data = json.dumps( table ) ptm.set_summary_cache( products[ product_name ], tr, json_data ) ptm.disconnect()
def buildTestSummaries(project): gm = DatazillaModel(project) timeRanges = utils.get_time_ranges() 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()
def _getTestRunSummary(project, method, request, dm): productIds = [] testIds = [] platformIds = [] ##### #Calling get_id_list() insures that we have only numbers in the #lists, this gaurds against SQL injection ##### if 'product_ids' in request.GET: productIds = utils.get_id_list(request.GET['product_ids']) if 'test_ids' in request.GET: testIds = utils.get_id_list(request.GET['test_ids']) if 'platform_ids' in request.GET: platformIds = utils.get_id_list(request.GET['platform_ids']) timeKey = 'days_30' timeRanges = utils.get_time_ranges() if 'tkey' in request.GET: timeKey = request.GET['tkey'] if not productIds: ##Set default productId## productIds = [12] jsonData = '{}' 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 = utils.get_cache_key(project, 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 = utils.get_cache_key( project, str(productIds[0]), timeKey, ) compressedJsonData = mc.get(key) if compressedJsonData: jsonData = zlib.decompress( compressedJsonData ) else: table = dm.getTestRunSummary(timeRanges[timeKey]['start'], timeRanges[timeKey]['stop'], productIds, platformIds, testIds) jsonData = json.dumps( table ) return jsonData
def _get_test_run_summary(project, method, request, dm): product_ids = [] test_ids = [] platform_ids = [] ##### #Calling get_id_list() insures that we have only numbers in the #lists, this gaurds against SQL injection ##### if 'product_ids' in request.GET: product_ids = utils.get_id_list(request.GET['product_ids']) if 'test_ids' in request.GET: test_ids = utils.get_id_list(request.GET['test_ids']) if 'platform_ids' in request.GET: platform_ids = utils.get_id_list(request.GET['platform_ids']) time_key = 'days_30' time_ranges = utils.get_time_ranges() if 'tkey' in request.GET: time_key = request.GET['tkey'] if not product_ids: ##Default to id 1 product_ids = [1] ##Set default product_id pck = dm.get_project_cache_key('default_product') default_product = cache.get(pck) ##If we have one use it if default_product: product_ids = [ int(default_product['id']) ] json_data = '{}' if product_ids and (not test_ids) and (not platform_ids): if len(product_ids) > 1: extend_list = { 'data':[], 'columns':[] } for id in product_ids: key = utils.get_summary_cache_key(project, str(id), time_key) compressed_json_data = cache.get(key) if compressed_json_data: json_data = zlib.decompress( compressed_json_data ) data = json.loads( json_data ) extend_list['data'].extend( data['data'] ) extend_list['columns'] = data['columns'] json_data = json.dumps(extend_list) else: key = utils.get_summary_cache_key( project, str(product_ids[0]), time_key, ) compressed_json_data = cache.get(key) if compressed_json_data: json_data = zlib.decompress( compressed_json_data ) else: table = dm.get_test_run_summary(time_ranges[time_key]['start'], time_ranges[time_key]['stop'], product_ids, platform_ids, test_ids) json_data = json.dumps( table ) return json_data