def get_result(): """Get the result for the crash stats page.""" params = dict(request.iterparams()) params['type'] = params.get('type', 'regression') page = helpers.cast(request.get('page') or 1, int, "'page' is not an int.") is_revision_empty = 'revision' not in params query = big_query_query.Query() crash_access.add_scope(query, params, 'security_flag', 'job_type', 'fuzzer_name') if is_revision_empty: total_count = 0 rows = [] else: filters.add(query, params, FILTERS) rows, total_count = get( params=params, query=query, offset=(page - 1) * PAGE_SIZE, limit=PAGE_SIZE) helpers.log('Regression', helpers.VIEW_OPERATION) result = { 'totalPages': (total_count // PAGE_SIZE) + 1, 'page': page, 'pageSize': PAGE_SIZE, 'items': rows, 'totalCount': total_count, 'isRevisionEmpty': is_revision_empty } return result, params
def test_array(self): """Test filtering multiple values.""" q = big_query_query.Query() q.filter_in('multi', [1, 1.2, True, False, 'test"test']) self.assertEqual('(multi IN (1, 1.2, true, false, "test\\"test"))', q.get_where_clause())
def test_single(self): """Test filtering single values.""" q = big_query_query.Query() q.filter('int', 123) q.filter('float', 123.456) q.filter('bool', True) q.filter('string', 'test"t\nest') self.assertEqual(('(int = 123 AND float = 123.456 AND bool = true AND ' 'string = "test\\"t\\nest")'), q.get_where_clause())
def test_nested_queries(self): """Test nested OR.""" q = big_query_query.Query() q.filter('q', 'test') s1_1 = q.new_subquery() s1_1.filter('s1_1', 'test') s1_2 = q.new_subquery() s1_2.filter('s1_2', 'test') s2_1 = q.new_subquery() s2_1.filter('s2_1', 'test') s2_2 = q.new_subquery() s2_2.filter('s2_2', 'test') q.union(s1_1, s1_2) s1_2.union(s2_1, s2_2) self.assertEqual( ('(q = "test" AND ((s1_1 = "test") OR (s1_2 = "test" AND ' '((s2_1 = "test") OR (s2_2 = "test")))))'), q.get_where_clause())
def test_two_groups(self): """Test OR in two separate groups.""" q = big_query_query.Query() q.filter('q', 'test') s1_1 = q.new_subquery() s1_1.filter('s1_1', 'test') s1_2 = q.new_subquery() s1_2.filter('s1_2', 'test') s2_1 = q.new_subquery() s2_1.filter('s2_1', 'test') s2_2 = q.new_subquery() s2_2.filter('s2_2', 'test') q.union(s1_1, s1_2) q.union(s2_1, s2_2) self.assertEqual( ('(q = "test" AND ((s1_1 = "test") OR (s1_2 = "test")) AND ' '((s2_1 = "test") OR (s2_2 = "test")))'), q.get_where_clause())