def get_user_activity():
    for platform in Total.select():
        UserActivity.create(
            source=platform.source,
            total=platform.total,
            active_count=platform.total - platform.default_good,
            active_percentage=calculate_percentage(platform.total, platform.total - platform.default_good),
            inactive_count=platform.default_good,
            inactive_percentage=calculate_percentage(platform.total, platform.default_good)
        )
Exemplo n.º 2
0
def mi10_sales():
    # 电商平台数据源概览
    total_source = []
    total_count = []
    total_good_rate = []
    for platform in Total.select():
        total_source.append(platform.source)
        total_count.append(rounding_w(platform.total))
        total_good_rate.append(float(platform.good_rate))
    # 各型号数据概览
    mc_name = []
    mc_per = []
    mc_good_rate = []
    for model in ModelCount.select():
        mc_name.append(model.product_color + '\n' + model.product_ram + '+' + model.product_rom)
        mc_per.append(model.percentage)
        mc_good_rate.append(float(model.good_rate))
    # 机身颜色百分比
    color_count = []
    for cc in ColorCount.select():
        color_count.append({'value': float(cc.percentage), 'name': cc.product_color})
    # 内存容量百分比
    ram_count = []
    for rac in RamCount.select():
        ram_count.append({'value': float(rac.percentage), 'name': rac.product_ram})
    # 储存容量百分比
    rom_count = []
    for roc in RomCount.select():
        rom_count.append({'value': float(roc.percentage), 'name': roc.product_rom})
    # 用户设备类型统计
    udc_per = []
    for udc in UserDeviceCount.select():
        udc_per.append({'value': float(udc.android_percentage), 'name': 'Android 留存用户'})
        udc_per.append({'value': float(udc.ios_percentage), 'name': 'iOS 转化用户'})
        udc_per.append({'value': float(udc.other_percentage), 'name': 'other'})

    return render_template('mi10_sales.html', total_source=total_source, total_count=total_count,
                           total_good_rate=total_good_rate, mc_name=mc_name, mc_per=mc_per, mc_good_rate=mc_good_rate,
                           color_count=color_count, ram_count=ram_count, rom_count=rom_count, udc_per=udc_per)