|
@@ -46,6 +46,56 @@ public class RuleParamHelper {
|
|
|
}
|
|
|
return groupShareRate;
|
|
|
}
|
|
|
+ public Double getGroupShareRateForBasic( Map<String, Object> abTestParam,Date nowDate,String midGroup){
|
|
|
+ String nowDt = dateFormat.format(nowDate);
|
|
|
+ String shareUserDataKey = (String) ((Map<String,Object>) abTestParam
|
|
|
+ .getOrDefault("user",defaultMap)).get("data");
|
|
|
+ String shareUserRuleKey = (String)
|
|
|
+ ((Map<String,Object>)abTestParam.getOrDefault("user",defaultMap)).get("rule");
|
|
|
+ String groupShareRateKey = RuleRedisKeyConst.KEY_NAME_PREFIX_AD_GROUP + shareUserDataKey + ":" + shareUserRuleKey + ":" + nowDt;
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(shareUserDataKey)||StringUtils.isEmpty(shareUserRuleKey)|| !redisHelper.contantinsKey(groupShareRateKey)) {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(nowDate);
|
|
|
+ cal.add(Calendar.DATE, -1);
|
|
|
+ Date yesterday = cal.getTime();
|
|
|
+ String redisDt = dateFormat.format(yesterday);
|
|
|
+ groupShareRateKey = RuleRedisKeyConst.KEY_NAME_PREFIX_AD_GROUP + shareUserDataKey + ":" + shareUserRuleKey + ":" + redisDt;
|
|
|
+ }
|
|
|
+
|
|
|
+ Double groupShareRate = redisHelper.zScore(groupShareRateKey, midGroup);
|
|
|
+ if(Objects.isNull(groupShareRate)){
|
|
|
+ groupShareRate=zeroDefaultValue;
|
|
|
+ }
|
|
|
+ return groupShareRate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Double getVideoShareRateForBasic( Map<String, Object> abTestParam,Date nowDate,Long videoId){
|
|
|
+ String nowDt = dateFormat.format(nowDate);
|
|
|
+ String shareVideoDataKey = (String)
|
|
|
+ ((Map<String,Object>)abTestParam
|
|
|
+ .getOrDefault("video",defaultMap)).get("data");
|
|
|
+ String videoShareRateKey = RuleRedisKeyConst.KEY_NAME_PREFIX_AD_VIDEO + shareVideoDataKey + ":" + nowDt;
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(shareVideoDataKey)||!redisHelper.contantinsKey(videoShareRateKey)) {
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.setTime(nowDate);
|
|
|
+ cal.add(Calendar.DATE, -1);
|
|
|
+ Date yesterday = cal.getTime();
|
|
|
+ String redisDt = dateFormat.format(yesterday);
|
|
|
+ videoShareRateKey = RuleRedisKeyConst.KEY_NAME_PREFIX_AD_VIDEO + shareVideoDataKey + ":" + redisDt;
|
|
|
+ }
|
|
|
+
|
|
|
+ Double videoShareRate = redisHelper.zScore(videoShareRateKey, videoId.toString());
|
|
|
+ if (videoShareRate == null) {
|
|
|
+ videoShareRate = redisHelper.zScore(videoShareRateKey, -1+"");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(videoShareRate)){
|
|
|
+ videoShareRate=zeroDefaultValue;
|
|
|
+ }
|
|
|
+ return videoShareRate;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public Double getVideoShareRate( Map<String, Object> abTestParam,Date nowDate,Long videoId){
|
|
|
String nowDt = dateFormat.format(nowDate);
|