Commit c0a78e0e authored by 刘基明's avatar 刘基明

格式化正文时间

parent 1bc324ab
...@@ -58,7 +58,7 @@ public class ThemeAnalysDO { ...@@ -58,7 +58,7 @@ public class ThemeAnalysDO {
double collectRatio = 3; double collectRatio = 3;
double userWeightRatio = 0.8; double userWeightRatio = 0.8;
double initialWeight = 1.0; double initialWeight = 1.0;
double timeRation = 0.3; double timeRation = 0.2;
// 质量=帖子质量+用户质量 // 质量=帖子质量+用户质量
double w = viewCount * viewRatio + forwardCount * forwardRatio + commentCount * commentRatio double w = viewCount * viewRatio + forwardCount * forwardRatio + commentCount * commentRatio
......
...@@ -43,6 +43,7 @@ import com.tanpu.community.util.BizUtils; ...@@ -43,6 +43,7 @@ import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil; import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.RankUtils; import com.tanpu.community.util.RankUtils;
import com.tanpu.community.util.TencentcloudUtils; import com.tanpu.community.util.TencentcloudUtils;
import com.tanpu.community.util.TimeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
...@@ -468,6 +469,9 @@ public class ThemeManager { ...@@ -468,6 +469,9 @@ public class ThemeManager {
//转发、收藏、点赞 //转发、收藏、点赞
buildThemeQoExtraInfo(themeQo); buildThemeQoExtraInfo(themeQo);
//时间重制
themeQo.setUpToNowTime(TimeUtils.format(themeEntity.getCreateTime()));
return themeQo; return themeQo;
} }
......
...@@ -15,6 +15,7 @@ import com.tanpu.community.util.TimeUtils; ...@@ -15,6 +15,7 @@ import com.tanpu.community.util.TimeUtils;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -29,6 +30,25 @@ import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USE ...@@ -29,6 +30,25 @@ import static com.tanpu.community.api.constants.RedisKeyConstant.CACHE_FEIGN_USE
@Service @Service
public class RankService { public class RankService {
@Value("${rank.theme.viewRatio:0.1}")
public Double viewRatio;
@Value("${rank.theme.forwardRatio:3}")
public Double forwardRatio;
@Value("${rank.theme.commentRatio:2}")
public Double commentRatio;
@Value("${rank.theme.likeRation:3}")
public Double likeRation;
@Value("${rank.theme.collectRatio:3}")
public Double collectRatio;
@Value("${rank.theme.userWeightRatio:0.9}")
public Double userWeightRatio;
@Value("${rank.theme.initialWeight:1.0}")
public Double initialWeight;
@Value("${rank.theme.timeRation:0.2}")
public Double timeRation;
@Autowired @Autowired
private ThemeService themeService; private ThemeService themeService;
@Autowired @Autowired
......
...@@ -172,9 +172,10 @@ public class RecommendService { ...@@ -172,9 +172,10 @@ public class RecommendService {
int round = 0; int round = 0;
while (true) { while (true) {
int hotStart = round * 3;
int newestStart = round * 6; int newestStart = round * newRatio;
int recmdStart = round; int hotStart = round * hotRatio;
int recmdStart = round * pythonRatio;
if (hotStart >= hotIds.size() && newestStart >= newestIds.size() && recmdStart >= recmdIds.size()) { if (hotStart >= hotIds.size() && newestStart >= newestIds.size() && recmdStart >= recmdIds.size()) {
break; break;
} }
......
...@@ -37,6 +37,11 @@ public class TimeUtils { ...@@ -37,6 +37,11 @@ public class TimeUtils {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
} }
//格式化时间
public static String format(LocalDateTime start) {
return start.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
}
//计算迄今分钟 //计算迄今分钟
public static long calMinuteTillNow(LocalDateTime start) { public static long calMinuteTillNow(LocalDateTime start) {
Duration between = Duration.between(start, LocalDateTime.now()); Duration between = Duration.between(start, LocalDateTime.now());
......
...@@ -94,4 +94,15 @@ recommend: ...@@ -94,4 +94,15 @@ recommend:
python: 1 python: 1
python: python:
enable: false enable: false
url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511 url: http://172.168.0.164:9000/api/get_recommend?user_id=2431614397151511
\ No newline at end of file
rank:
theme:
viewRatio: 0.1
forwardRatio: 3
commentRatio: 2
likeRation: 1
collectRatio: 3
userWeightRatio: 0.9
initialWeight: 1.0
timeRation: 0.2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment