Пример #1
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',
Пример #2
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)
Пример #3
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',
Пример #4
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)
Пример #5
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 last 30 days',
    description='The revenue generated from the product in the last 30 days',
    aggregation=Aggregation.SUM,
    column_name='revenue_last_30_days',
    important_field=True)

products_data_set.add_simple_metric(
    name='# Items on stock',
    description=
    'How many items of the products are in stock according to the ERP (at the time of the last DWH import)',
    column_name='number_of_items_on_stock',
    aggregation=Aggregation.SUM,
    important_field=True)
Пример #6
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', 'Customer'])

customers_data_set.add_simple_metric(
    name='# Orders',
    description='Number of orders placed by the customer',
    aggregation=Aggregation.SUM,
    column_name='number_of_orders',
    important_field=True)

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

customers_data_set.add_composed_metric(
    name='AOV',
    description='The average revenue per order of the customer',
    formula='[CLV] / [# Orders]')
Пример #7
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.include_attributes(['Order', 'Customer', 'Order'],
                                        ['Order date'])

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',
    aggregation=Aggregation.DISTINCT_COUNT,
    important_field=True)

order_items_data_set.add_simple_metric(
    name='Product revenue',
    description='The price of the ordered products as shown in the cart',
    aggregation=Aggregation.SUM,
    column_name='product_revenue',
    important_field=True)

order_items_data_set.add_simple_metric(
    name='Shipping revenue',