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;

/**
 * 分地域24h
 *
 * @author dyp
 */
@Service
public class RegionRelative24HDupRecallStrategy extends AbstractRegionRecallStrategy {
    public static final String PUSH_FORM = "rov_recall_24h_dup";
    public static final String LAST_VIDEO_KEY_FORMAT = "recall:last:item:region:dup3:24h:%s:%s";

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

    @Override
    protected String poolKey(RecallParam param, String now_dt, int h) {
        return String.format("recall:item:score:region:dup3:24h:%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;
    }
}
