package com.tzld.piaoquan.recommend.server.service.recall.strategy;

import com.tzld.piaoquan.recommend.server.service.recall.RecallParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 不区分地域小时
 *
 * @author dyp
 */
@Service
public class RegionHDupRecallStrategy extends AbstractRegionRecallStrategy {
    public static final String PUSH_FORM = "rov_recall_h_h";
    public static final String LAST_VIDEO_KEY_FORMAT = "recall:last:item:region:dup:h:%s:%s";

    @Override
    protected String recordKey(RecallParam param) {
        return String.format("recall:last:record:region:dup:h:%s:%s", param.getAppType(), param.getMid());
    }

    @Override
    protected String poolKey(RecallParam param, String now_dt, int h) {
        // hard code  因为生产任务，会给region填充默认值-1
        return String.format("recall:item:score:region:dup:h:%s:%s:%s:%s:%s",
                StringUtils.isBlank(param.getRegionCode()) ? -1 : param.getRegionCode(),
                param.getDataKey(), param.getRuleKey(), now_dt, h);
    }

    @Override
    protected String lastVideoKey(RecallParam param) {
        return String.format(LAST_VIDEO_KEY_FORMAT, param.getAppType(), param.getMid());
    }

    @Override
    public String pushFrom() {
        return PUSH_FORM;
    }
}
