source /etc/profile

now_date=`date  +"%Y%m%d%H" -d -0days`
echo ${now_date}
echo $ROV_OFFLINE_ENV

if [[ $ROV_OFFLINE_ENV == 'test' ]]; then
    cd /data2/rov-offline
elif [[ $ROV_OFFLINE_ENV == 'pro' ]]; then
    cd /data/rov-offline
fi

mkdir -p ./data/

# 1. 获取24h数据
/root/anaconda3/bin/python export_24h_vid.py  ${now_date}
if [ $? -ne 0 ];
then
    msg = "[ERROR] sorted extract_vid_log"
    echo "[ERROR] echo 'extract_vid.py"
    exit 255
fi

# 2. 获取小时级数据
/root/anaconda3/bin/python export_hour_vid.py ${now_date}
if [ $? -ne 0 ];
then
    msg = "[ERROR] sorted extract_hour_log"
    echo "[ERROR] echo 'extract_hour_vid.py"
    exit 255
fi

# 3. 计算24h分值
/root/anaconda3/bin/python cal_24h_score.py ${now_date}
if [ $? -ne 0 ];
then
    msg = "[ERROR] cal  ctr "
    echo "[ERROR] echo 'calCtr.py"
    exit 255
fi

# 4. 计算小时级分值
/root/anaconda3/bin/python cal_hour_score.py ${now_date}
if [ $? -ne 0 ];
then
    msg = "[ERROR] cal hour ctr "
    echo "[ERROR] echo 'calCtr.py"
    exit 255
fi

# 5. 分值合并
/root/anaconda3/bin/python compose_score.py ${now_date}
if [ $? -ne 0 ];
then
    msg = "[ERROR] cal compose_score "
    echo "[ERROR] echo 'compose_score.py"
    exit 255
fi

# 6. 过期数据清除
sh clean.sh
echo "finish sorted"

