package examples.dataloader;


import com.aliyun.odps.account.Account;
import com.aliyun.odps.account.AliyunAccount;
import com.aliyun.odps.data.Record;
import com.tzld.piaoquan.recommend.feature.domain.video.base.*;

import java.util.HashMap;
import java.util.Map;

public class RecommRedisFeatureConstructor {



    public static UserFeature constructUserFeature(Record record) {
        UserFeature userFeature = new UserFeature();
        userFeature.setUid(String.valueOf(record.getBigint("uid")));
        userFeature.setMid(record.getString("mids").toString());
        userFeature.setUser_cycle_bucket_7days(record.getString("u_cycle_bucket_7days"));
        userFeature.setUser_cycle_bucket_30days(record.getString("u_cycle_bucket_30days"));
        userFeature.setUser_share_bucket_30days(record.getString("u_share_bucket_30days"));


        // 1day features
        UserActionFeature user1dayActionFeature = new UserActionFeature();
        user1dayActionFeature.setOriginExp_cnt(record.getString("u_1day_exp_cnt"));
        user1dayActionFeature.setOriginClick_cnt(record.getString("u_1day_click_cnt"));
        user1dayActionFeature.setOriginShare_cnt(record.getString("u_1day_share_cnt"));
        user1dayActionFeature.setOriginReturn_cnt(record.getString("u_1day_return_cnt"));
        user1dayActionFeature.setOriginCtr(record.getString("u_ctr_1day"));
        user1dayActionFeature.setOriginStr(record.getString("u_str_1day"));
        user1dayActionFeature.setOriginRov(record.getString("u_rov_1day"));
        user1dayActionFeature.setOriginRos(record.getString("u_ros_1day"));
        userFeature.setDay1_cnt_features(user1dayActionFeature);

        // 3day features
        UserActionFeature user3dayActionFeature = new UserActionFeature();
        user3dayActionFeature.setOriginExp_cnt(record.getString("u_3day_exp_cnt"));
        user3dayActionFeature.setOriginClick_cnt(record.getString("u_3day_click_cnt"));
        user3dayActionFeature.setOriginShare_cnt(record.getString("u_3day_share_cnt"));
        user3dayActionFeature.setOriginReturn_cnt(record.getString("u_3day_return_cnt"));
        user3dayActionFeature.setOriginCtr(record.getString("u_ctr_3day"));
        user3dayActionFeature.setOriginStr(record.getString("u_str_3day"));
        user3dayActionFeature.setOriginRov(record.getString("u_rov_3day"));
        user3dayActionFeature.setOriginRos(record.getString("u_ros_3day"));
        userFeature.setDay3_cnt_features(user3dayActionFeature);

        // 7day features
        UserActionFeature user7dayActionFeature = new UserActionFeature();
        user7dayActionFeature.setOriginExp_cnt(record.getString("u_7day_exp_cnt"));
        user7dayActionFeature.setOriginClick_cnt(record.getString("u_7day_click_cnt"));
        user7dayActionFeature.setOriginShare_cnt(record.getString("u_7day_share_cnt"));
        user7dayActionFeature.setOriginReturn_cnt(record.getString("u_7day_return_cnt"));
        user7dayActionFeature.setOriginCtr(record.getString("u_ctr_7day"));
        user7dayActionFeature.setOriginStr(record.getString("u_str_7day"));
        user7dayActionFeature.setOriginRov(record.getString("u_rov_7day"));
        user7dayActionFeature.setOriginRos(record.getString("u_ros_7day"));
        userFeature.setDay7_cnt_features(user7dayActionFeature);

        // 3month features
        UserActionFeature user3monthActionFeature = new UserActionFeature();
        user3monthActionFeature.setOriginExp_cnt(record.getString("u_3month_exp_cnt"));
        user3monthActionFeature.setOriginClick_cnt(record.getString("u_3month_click_cnt"));
        user3monthActionFeature.setOriginShare_cnt(record.getString("u_3month_share_cnt"));
        user3monthActionFeature.setOriginReturn_cnt(record.getString("u_3month_return_cnt"));
        user3monthActionFeature.setOriginCtr(record.getString("u_ctr_3month"));
        user3monthActionFeature.setOriginStr(record.getString("u_str_3month"));
        user3monthActionFeature.setOriginRov(record.getString("u_rov_3month"));
        user3monthActionFeature.setOriginRos(record.getString("u_ros_3month"));
        userFeature.setMonth3_cnt_features(user3monthActionFeature);

        return userFeature;
    }


    public static ItemFeature constructItemFeature(Record record) {
        ItemFeature itemFeature = new ItemFeature();
        itemFeature.setVideoId(String.valueOf(record.getBigint("videoid")));
        itemFeature.setUpId(String.valueOf(record.getBigint("uid")));
        itemFeature.setPlayLength(String.valueOf(record.getBigint("play_count")));
        itemFeature.setTotalTime(String.valueOf(record.getBigint("total_time")));
        itemFeature.setDaysSinceUpload(String.valueOf(record.getDouble("existence_days")));

        UserActionFeature user1dayActionFeature = new UserActionFeature();
        user1dayActionFeature.setOriginExp_cnt(record.getString("i_1day_exp_cnt"));
        user1dayActionFeature.setOriginClick_cnt(record.getString("i_1day_click_cnt"));
        user1dayActionFeature.setOriginShare_cnt(record.getString("i_1day_share_cnt"));
        user1dayActionFeature.setOriginReturn_cnt(record.getString("i_1day_return_cnt"));
        user1dayActionFeature.setOriginCtr(record.getString("i_ctr_1day"));
        user1dayActionFeature.setOriginStr(record.getString("i_str_1day"));
        user1dayActionFeature.setOriginRov(record.getString("i_rov_1day"));
        user1dayActionFeature.setOriginRos(record.getString("i_ros_1day"));
        itemFeature.setDay1_cnt_features(user1dayActionFeature);

        UserActionFeature user3dayActionFeature = new UserActionFeature();
        user3dayActionFeature.setOriginExp_cnt(record.getString("i_3day_exp_cnt"));
        user3dayActionFeature.setOriginClick_cnt(record.getString("i_3day_click_cnt"));
        user3dayActionFeature.setOriginShare_cnt(record.getString("i_3day_share_cnt"));
        user3dayActionFeature.setOriginReturn_cnt(record.getString("i_3day_return_cnt"));
        user3dayActionFeature.setOriginCtr(record.getString("i_ctr_3day"));
        user3dayActionFeature.setOriginStr(record.getString("i_str_3day"));
        user3dayActionFeature.setOriginRov(record.getString("i_rov_3day"));
        user3dayActionFeature.setOriginRos(record.getString("i_ros_3day"));
        itemFeature.setDay3_cnt_features(user1dayActionFeature);

        UserActionFeature user7dayActionFeature = new UserActionFeature();
        user7dayActionFeature.setOriginExp_cnt(record.getString("i_7day_exp_cnt"));
        user7dayActionFeature.setOriginClick_cnt(record.getString("i_7day_click_cnt"));
        user7dayActionFeature.setOriginShare_cnt(record.getString("i_7day_share_cnt"));
        user7dayActionFeature.setOriginReturn_cnt(record.getString("i_7day_return_cnt"));
        user7dayActionFeature.setOriginCtr(record.getString("i_ctr_7day"));
        user7dayActionFeature.setOriginStr(record.getString("i_str_7day"));
        user7dayActionFeature.setOriginRov(record.getString("i_rov_7day"));
        user7dayActionFeature.setOriginRos(record.getString("i_ros_7day"));
        itemFeature.setDay7_cnt_features(user1dayActionFeature);

        UserActionFeature user3monthActionFeature = new UserActionFeature();
        user3monthActionFeature.setOriginExp_cnt(record.getString("i_3month_exp_cnt"));
        user3monthActionFeature.setOriginClick_cnt(record.getString("i_3month_click_cnt"));
        user3monthActionFeature.setOriginShare_cnt(record.getString("i_3month_share_cnt"));
        user3monthActionFeature.setOriginReturn_cnt(record.getString("i_3month_return_cnt"));
        user3monthActionFeature.setOriginCtr(record.getString("i_ctr_3month"));
        user3monthActionFeature.setOriginStr(record.getString("i_str_3month"));
        user3monthActionFeature.setOriginRov(record.getString("i_rov_3month"));
        user3monthActionFeature.setOriginRos(record.getString("i_ros_3month"));
        itemFeature.setMonth3_cnt_features(user3monthActionFeature);
        return itemFeature;
    }


}
