package com.reyun.util;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;

import java.util.Collection;

/**
 * Created by nolan on 19/01/2017.
 * description:
 */
public class ViewColumnDependUtil {
    private static Multimap<String, String> multimap = ArrayListMultimap.create();

    static {
        //激活率=激活设备数/排重点击
        multimap.put("rate_install", "num_install");
        multimap.put("rate_install", "dupnum_click_all");
        //注册率=注册设备数/激活设备数
        multimap.put("rate_reged", "dupnum_reged_day");
        multimap.put("rate_reged", "num_install");
        //异常点击率=异常点击设备数/点击总数
        multimap.put("rate_click_fake", "num_click_fake");
        multimap.put("rate_click_fake", "num_click_total");
        //异常激活率=异常激活设备数/激活设备数
        multimap.put("rate_install_fake", "num_install_fake");
        multimap.put("rate_install_fake", "num_install");
        //n日留存率=sum(激活设备数n日留存设备数)*100.0/sum(激活设备数)
        multimap.put("rate_retentiond1", "rate_retentiond1");
        multimap.put("rate_retentiond1", "num_install");
        multimap.put("rate_retentiond3", "rate_retentiond3");
        multimap.put("rate_retentiond3", "num_install");
        multimap.put("rate_retentiond7", "rate_retentiond7");
        multimap.put("rate_retentiond7", "num_install");
        multimap.put("rate_retentiond30", "rate_retentiond30");
        multimap.put("rate_retentiond30", "num_install");
        //ltvn=sum(n日LTV值)/sum(激活设备数)
        multimap.put("amt_ltv0", "amt_ltv0");
        multimap.put("amt_ltv0", "num_install");
        multimap.put("amt_ltv7", "amt_ltv7");
        multimap.put("amt_ltv7", "num_install");
        multimap.put("amt_ltv30", "amt_ltv30");
        multimap.put("amt_ltv30", "num_install");
        //arpu=注收比付费/排重激活设备数
        multimap.put("arpu","amt_amount");
        multimap.put("arpu","num_ins");
        //arpu=注收比付费/付费设备数
        multimap.put("arppu","amt_amount");
        multimap.put("arppu","num_pay");
        //付费率=付费设备数*100.0/排重激活设备数
        multimap.put("rate_pay","num_pay");
        multimap.put("rate_pay","num_ins");
        //H5注册率=注册用户/排重点击
        multimap.put("rate_reged_h5","num_register");
        multimap.put("rate_reged_h5","num_click");
    }

    public static Multiset<String> getRateKeyFields() {
        return multimap.keys();
    }

    public static Collection<String> getRateDependFields(String ratefield) {
        return multimap.get(ratefield);
    }
}
