#!/bin/sh

# # # # # # # # # # # # # # # # # # # # # #
# @author  : wangjf
# @revision: 2019-03-04 15:23:33
# @desc :  将当天 iqiyi 添加到ods_dmp_user_info表
# # # # # # # # # # # # # # # # # # # # # #

source ../dmp_env.sh

today=${ScheduleTime:-$1}
dt=$(date +"%Y%m%d" -d "$today")
date=$(date +"%Y-%m-%d" -d "$today")
date_path=$(date +%Y/%m/%d -d "$today")
old_path=$(date +%Y/%m/%d -d "-1 day $today")
expire_date=$(date +%Y%m%d -d "-6 day $today")
expire_path=$(date +%Y/%m/%d -d "-6 day $today")

business_name="iqiyi_api"
daily_path="${IQiYi_DAILY_PATH}/$date_path"

old_total_path="${ODS_DMP_USER_INFO}/$old_path/${business_name}"
OUTPUT_PATH="${ODS_DMP_USER_INFO}/$date_path/${business_name}"

age_path="${DMP_AGE_CALC_DEVICE}/$date_path"
gender_path="${GENDER_MERGE_DEVICE}/$date_path"

unmount_path="${ODS_DMP_USER_INFO}/$expire_path/${business_name}"

# coalesce=`calculate_reduce_num "${old_total_path};${daily_path}"`
# coalesce=$(( $coalesce*5 ))
coalesce=10

check_await "${old_total_path}/_SUCCESS"

userInfoJob "$date" "$daily_path" "orc" "0" "1" "2" "4" "$age_path" "$gender_path" "$old_total_path" "$OUTPUT_PATH" ${coalesce} "../${JAR}" 20 10

mount_partition "ods_dmp_user_info" "dt='${dt}', business='${business_name}'" "$OUTPUT_PATH"

unmount_partition "ods_dmp_user_info" "dt='${expire_date}', business='${business_name}'" "$unmount_path"