|
@@ -3,8 +3,10 @@ package com.tzld.longarticle.recommend.server.service.score.strategy;
|
|
|
import com.tzld.longarticle.recommend.server.model.Content;
|
|
|
import com.tzld.longarticle.recommend.server.repository.adplatform.ChangwenArticleDatastatRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.adplatform.ChangwenArticleRepository;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.entity.adplatform.ChangwenArticle;
|
|
|
import com.tzld.longarticle.recommend.server.repository.entity.adplatform.ChangwenArticleDatastat;
|
|
|
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.AccountAvgInfo;
|
|
|
import com.tzld.longarticle.recommend.server.service.AccountIndexAvgViewCountService;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.Score;
|
|
|
import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
|
|
@@ -32,6 +34,8 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
|
|
|
ChangwenArticleDatastatRepository changwenArticleDatastatRepository;
|
|
|
@Autowired
|
|
|
AccountIndexAvgViewCountService accountIndexAvgViewCountService;
|
|
|
+ @Autowired
|
|
|
+ AccountAvgInfoRepository accountAvgInfoRepository;
|
|
|
|
|
|
@Override
|
|
|
public List<Score> score(ScoreParam param) {
|
|
@@ -44,6 +48,7 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
|
|
|
Map<String, ChangwenArticle> changwenArticleDTOMap = getContentIndex(channelContentIds);
|
|
|
Map<String, ChangwenArticleDatastat> changwenArticleDatastatDTOMap = getContentViewCount(channelContentIds);
|
|
|
|
|
|
+ List<AccountAvgInfo> avgInfoList = accountAvgInfoRepository.getAllByStatusEquals(1);
|
|
|
List<Score> scores = CommonCollectionUtils.toList(param.getContents(), c -> {
|
|
|
Score score = new Score();
|
|
|
score.setContentId(c.getId());
|
|
@@ -51,7 +56,7 @@ public class ViewMultiplierStrategy implements ScoreStrategy {
|
|
|
ChangwenArticleDatastat datastat = changwenArticleDatastatDTOMap.get(c.getCrawlerChannelContentId());
|
|
|
|
|
|
if (Objects.nonNull(article) && Objects.nonNull(datastat)) {
|
|
|
- double avgReadCount = accountIndexAvgViewCountService.getAvgReadCountByDB(article.getAccountId(), article.getItemIndex());
|
|
|
+ double avgReadCount = accountIndexAvgViewCountService.getAvgReadCountByDB(avgInfoList, article.getAccountId(), article.getItemIndex());
|
|
|
Integer readCount = datastat.getReadCount();
|
|
|
score.setScore(NormalizationUtils.min(Math.max(readCount, 0) / avgReadCount - 1));
|
|
|
} else {
|