예제 #1
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def recent_sales(**kwargs):
    blue_panel = IndicatorPanel(connection, q.query_sales_last_week)
    blue_panel.set_values('blue', 'shopping_cart', 'Sales Last Week')
    blue_panel.panel_num = '$' + str(blue_panel.panel_num)
    yellow_panel = IndicatorPanel(connection, q.query_sales_last_day)
    yellow_panel.set_values('yellow', 'shopping_cart', 'Sales Last Day')
    context = {
        'panels_html': [
            blue_panel.get_html_rep(),
            yellow_panel.get_html_rep(),
        ],
        'sales_last_month_json': read_sales_last_month_over_time(),
    }
    return render_template('recent_sales.html', context=context, **kwargs)
예제 #2
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def alltime_sales(**kwargs):
    blue_panel = IndicatorPanel(connection, q.query_rentals_all_time)
    blue_panel.set_values('blue', 'shopping_cart', 'All-Time Rentals')
    yellow_panel = IndicatorPanel(connection, q.query_sales_all_time)
    yellow_panel.set_values('yellow', 'shopping_cart', 'All-Time Sales')
    yellow_panel.panel_num = '$ ' + str(yellow_panel.panel_num)
    green_panel = IndicatorPanel(connection, q.query_all_time_sales_over_units)
    green_panel.set_values('green', 'tasks', 'Avg. All-Time Sales per Unit in '
        'Stock')
    green_panel.panel_num = '%.2f' % green_panel.panel_num
    green_panel.panel_num = '$ ' + str(green_panel.panel_num)
    red_panel = IndicatorPanel(connection, q.query_least_profitable_genre)
    red_panel.set_values('red', 'support', 'Least Profitable Genre')
    red_panel.panel_num = 'Travel'

    context = {
        'panels_html': [
            blue_panel.get_html_rep(),
            yellow_panel.get_html_rep(),
            green_panel.get_html_rep(),
            red_panel.get_html_rep(),
        ],
        'sales_by_genre_table': read_sales_by_genre(),
        'sales_over_inventory_json': read_sales_over_inventory(),
    }
    return render_template('alltime_sales.html', context=context, **kwargs)
예제 #3
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def inventory(**kwargs):
    blue_panel = IndicatorPanel(connection, q.query_films_in_inventory)
    blue_panel.set_values('blue', 'shopping_cart',
                          'Film Titles in Inventory')
    green_panel = IndicatorPanel(connection, q.query_films_checked_out)
    green_panel.set_values('green', 'shopping_cart', 'Films Checked Out')
    yellow_panel = IndicatorPanel(connection,
                                  q.query_avg_length_time_movies_rented)
    yellow_panel.set_values('yellow', 'tasks',
                            'Avg. Days Film Checked Out')
    yellow_panel.panel_num = '%.2f' % green_panel.panel_num
    red_panel = IndicatorPanel(connection,
                               q.query_number_rentals_returned_late)
    red_panel.set_values('red', 'tasks', 'Rentals Returned Late')
    context = {
        'panels_html': [
            blue_panel.get_html_rep(),
            green_panel.get_html_rep(),
            yellow_panel.get_html_rep(),
            red_panel.get_html_rep(),
        ],
        'table_films_by_category': read_films_in_inventory_by_category(),
        'table_films_by_store': read_films_in_inventory_by_store(),
        'table_top_rented_films': read_films_in_inventory_most_rented(),
    }
    return render_template('inventory.html', context=context, **kwargs)
예제 #4
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def employees(**kwargs):
    blue_panel = IndicatorPanel(connection, None)
    blue_panel.set_values('blue', 'tasks', 'Employee Retetention Rate')
    blue_panel.panel_num = ('100%')
    yellow_panel = IndicatorPanel(connection, q.query_avg_rental_by_staff)
    yellow_panel.set_values('yellow', 'shopping_cart',
                            'Average Sales per Employee')
    yellow_panel.panel_num = '%0.0f' % yellow_panel.panel_num
    yellow_panel.panel_num = '$' + str(yellow_panel.panel_num)
    context = {
        'panels_html': [
            yellow_panel.get_html_rep(),
            blue_panel.get_html_rep()
        ],
        'sales_by_employee_table': read_sales_by_employee_over_time(),
    }
    return render_template('employees.html', context=context, **kwargs)
예제 #5
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def customers(**kwargs):
    yellow_panel = IndicatorPanel(connection, q.query_active_customers)
    yellow_panel.set_values('yellow', 'shopping_cart', 'Active Customers')
    green_panel = IndicatorPanel(connection,
                                q.query_customers_added_last_month)
    green_panel.set_values('green', 'tasks', 'Customers Gained Last Month')
    red_panel = IndicatorPanel(connection, q.query_customers_lost_last_month)
    red_panel.set_values('red', 'support', 'Customers Lost Last Month')
    blue_panel = IndicatorPanel(connection, None)
    blue_panel.set_values('blue', 'tasks', 'Customer Retention Rate')
    blue_panel.panel_num = calc_customer_retention_rate()
    context = {
        'panels_html': [
            yellow_panel.get_html_rep(),
            green_panel.get_html_rep(),
            red_panel.get_html_rep(),
            blue_panel.get_html_rep(),

        ],
        'customer_origin_table': read_customers_by_country(),
        'customer_lost_origin_table': read_customers_lost_by_country(),
        'donut_chart': {'active_customers':
                        read_number_active_customers(),
                        'inactive_customers':
                        read_customers_lost_last_month(),
                        },
    }
    return render_template('customers.html', context=context, **kwargs)
예제 #6
0
파일: run.py 프로젝트: rowanv/giraffe_dash
def index(**kwargs):

    green_panel = IndicatorPanel(connection, None)
    green_panel.set_values('green', 'comments', 'New Orders!')
    green_panel.panel_num = ('1')
    red_panel = IndicatorPanel(connection, q.query_customers_lost_last_month)
    red_panel.set_values('red', 'support', 'Customers Lost Last Month')
    blue_panel = IndicatorPanel(connection, None)
    blue_panel.set_values('blue', 'tasks', 'Customer Retention Rate')
    blue_panel.panel_num = calc_customer_retention_rate()
    yellow_panel = IndicatorPanel(connection, q.query_films_checked_out)
    yellow_panel.set_values('yellow', 'shopping_cart', 'Films Checked Out')

    context = {'panels_html': [
        blue_panel.get_html_rep(),
        green_panel.get_html_rep(),
        yellow_panel.get_html_rep(),
        red_panel.get_html_rep(),
    ],
        'donut_chart': {'active_customers':
                        read_number_active_customers(),
                        'inactive_customers':
                        read_customers_lost_last_month(),
                        },
        'table_films_by_category': read_films_in_inventory_by_category(),
    }
    return render_template('index.html', context=context, **kwargs)