def test_nb_sales_by_shop_limited_size(elasticsearch_sale): # Nb sales by shop limited size write_fquery_output( FQuery(get_search(), default_size=2).values(Count(Sale), ).group_by(Sale.shop_id, ), 'nb_sales_by_shop_limited_size', )
def test_nb_sales_by_product_type(elasticsearch_sale): # Nb sales by product_type write_fquery_output( FQuery(get_search()).values(ReverseNested( Sale, Count(Sale), ), ).group_by(Sale.product_type, ), 'nb_sales_by_product_type', )
def test_nb_sales_by_grouped_shop(elasticsearch_sale, shops_by_group): # Nb sales by grouped shop id write_fquery_output( FQuery(get_search()).values(Count(Sale), ).group_by( GroupedField( Sale.shop_id, groups=shops_by_group, ), ), 'nb_sales_by_grouped_shop', )
def test_nb_sales_by_date_range_with_keys(elasticsearch_sale, date_ranges_with_keys): write_fquery_output( FQuery(get_search()).values(Count(Sale), ).group_by( DateRange( Sale.timestamp, ranges=date_ranges_with_keys, ), ), 'nb_sales_by_date_range_with_keys', )
def test_generate_performance_output(elasticsearch_sale): write_fquery_output( FQuery(get_search()).values(Count(Sale), ).group_by( DateHistogram( Sale.timestamp, interval='15m', min=start, max=end, )), 'nb_sales_by_15_minutes_performance', )
def test_nb_sales_by_payment_type_by_date_range(elasticsearch_sale, date_ranges_with_keys): # Nb sales by payment type by date range write_fquery_output( FQuery(get_search()).values(Count(Sale), ).group_by( Sale.payment_type, DateRange( Sale.timestamp, ranges=date_ranges_with_keys, ), ), 'nb_sales_by_payment_type_by_date_range', )
def test_flatten_performance(): fquery = FQuery(get_search()).values(Count(Sale), ).group_by( DateHistogram( Sale.timestamp, interval='15m', min=start, max=end, ), ) result = load_output('nb_sales_by_15_minutes_performance') fquery._flatten_result( result, remove_nested_aggregations=fquery._contains_nested_expressions(), )
def test_nb_sales_by_date_range_without_keys(elasticsearch_sale): # Nb sales by date range without keys ranges_without_keys = [ { 'from': datetime(2016, 1, 1), 'to': datetime(2016, 1, 15), }, { 'from': datetime(2016, 1, 15), 'to': datetime(2016, 1, 31), }, ] write_fquery_output( FQuery(get_search()).values(Count(Sale), ).group_by( DateRange( Sale.timestamp, ranges=ranges_without_keys, ), ), 'nb_sales_by_date_range_without_keys', )
def test_nb_sales_by_shop(elasticsearch_sale): # Number of sales by shop write_fquery_output( FQuery(get_search()).values(Count(Sale.id), ).group_by(Sale.shop_id, ), 'nb_sales_by_shop', )