Example #1
0
from mara_schema.data_set import DataSet, Aggregation

from ..entities.product import product_entity

products_data_set = DataSet(entity=product_entity, name='Products')

products_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description='The lifetime revenue generated from this product',
    aggregation=Aggregation.SUM,
    column_name='product_revenue',
    important_field=True)
Example #2
0
from mara_schema.data_set import DataSet, Aggregation

from ..entities.order_item import order_item_entity

order_items_data_set = DataSet(entity=order_item_entity, name='Order items')

order_items_data_set.exclude_path(
    ['Order', 'Customer', ('Order', 'Last order')])
order_items_data_set.exclude_path(['Seller', ('Order', 'First order')])

order_items_data_set.include_attributes(['Order'], [
    'Order date', 'Order status', 'Payment approval date', 'Delivery date',
    'Delivery time in days', 'Days since first order'
])
order_items_data_set.include_attributes(
    ['Order', 'Customer', ('Order', 'First order')], ['Order date'])
order_items_data_set.include_attributes(['Order', 'Customer', 'Zip code'],
                                        ['Zip code', 'City', 'State'])
order_items_data_set.include_attributes(['Seller', 'Zip code'],
                                        ['Zip code', 'City', 'State'])

order_items_data_set.add_simple_metric(
    name='# Order items',
    description='The number of ordered products',
    column_name='order_item_id',
    aggregation=Aggregation.COUNT)

order_items_data_set.add_simple_metric(
    name='# Orders',
    description='The number of valid orders (orders with an invoice)',
    column_name='order_fk',
Example #3
0
from mara_schema.data_set import DataSet, Aggregation

from ..entities.seller import seller_entity

sellers_data_set = DataSet(entity=seller_entity, name='Sellers')

sellers_data_set.exclude_path([('Order', 'First order'), 'Customer'])

sellers_data_set.include_attributes(['Zip code'],
                                    ['Zip code', 'City', 'State'])

sellers_data_set.include_attributes(['Order'], ['Order date'])

sellers_data_set.add_simple_metric(
    name='# Orders (lifetime)',
    description='Number of orders with at-least one product fulfilled by this seller',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders_lifetime')

sellers_data_set.add_simple_metric(
    name='# Order items (lifetime)',
    description='Number of products sold by this seller',
    aggregation=Aggregation.SUM,
    column_name='number_of_order_items_lifetime')

sellers_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description='The lifetime revenue generated from products sold by this seller',
    aggregation=Aggregation.SUM,
    column_name='revenue_lifetime',
    important_field=True)
Example #4
0
from mara_schema.data_set import DataSet, Aggregation

from ..entities.customer import customer_entity

customers_data_set = DataSet(entity=customer_entity, name='Customers')

customers_data_set.exclude_path([('Order', 'First order'), 'Customer'])
customers_data_set.exclude_path([('Order', 'Last order'), 'Customer'])

customers_data_set.include_attributes(['Zip code'],
                                      ['Zip code', 'City', 'State'])
customers_data_set.include_attributes([('Order', 'First order')],
                                      ['Order date'])
customers_data_set.include_attributes([('Order', 'Last order')],
                                      ['Order date'])

customers_data_set.add_simple_metric(
    name='# Orders (lifetime)',
    description='Number of orders placed by this customer',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders_lifetime')

customers_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description='The lifetime revenue generated from products purchased by this customer',
    aggregation=Aggregation.SUM,
    column_name='revenue_lifetime',
    important_field=True)

customers_data_set.add_composed_metric(
    name='AOV',
Example #5
0
from mara_schema.data_set import DataSet, Aggregation

from ..entities.lead import lead_entity

leads_data_set = DataSet(entity=lead_entity, name='Leads')

leads_data_set.exclude_path(['Seller', ('Order', 'First order'), 'Customer'])

leads_data_set.include_attributes(['Seller', 'Zip code'],
                                  ['Zip code', 'City', 'State'])
leads_data_set.include_attributes(['Seller', ('Order', 'First order')],
                                  ['Order date'])

leads_data_set.add_simple_metric(
    name='# Orders (lifetime)',
    description=
    'Number of orders with at-least one product fulfilled by this seller',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders_lifetime')

leads_data_set.add_simple_metric(
    name='Revenue (lifetime)',
    description=
    'The lifetime revenue generated from products sold by this seller',
    aggregation=Aggregation.SUM,
    column_name='revenue_lifetime',
    important_field=True)

leads_data_set.add_composed_metric(
    name='AOV',
    description=