|
@@ -7,7 +7,10 @@ import com.tzld.longarticle.recommend.server.repository.aigc.CrawlerMetaArticleR
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
|
|
|
import com.tzld.longarticle.recommend.server.repository.entity.crawler.PublishSortLog;
|
|
|
import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
|
|
|
-import com.tzld.longarticle.recommend.server.service.score.*;
|
|
|
+import com.tzld.longarticle.recommend.server.service.score.AccountPublishTimesConfig;
|
|
|
+import com.tzld.longarticle.recommend.server.service.score.Score;
|
|
|
+import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
|
|
|
+import com.tzld.longarticle.recommend.server.service.score.ScoreStrategy;
|
|
|
import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -38,7 +41,7 @@ public class PublishTimesStrategy implements ScoreStrategy {
|
|
|
if (CollectionUtils.isEmpty(param.getContents())) {
|
|
|
return scores;
|
|
|
}
|
|
|
- AccountPublishTimesConfig[] indexPublishTimesArr = accountPublishTimesConfigMap.get(param.getAccountName());
|
|
|
+ AccountPublishTimesConfig[] indexPublishTimesArr = getPublishTimes(param.getAccountName());
|
|
|
if (Objects.isNull(indexPublishTimesArr) || indexPublishTimesArr.length == 0) {
|
|
|
return scores;
|
|
|
}
|
|
@@ -53,20 +56,21 @@ public class PublishTimesStrategy implements ScoreStrategy {
|
|
|
score.setStrategy(this);
|
|
|
score.setContentId(content.getId());
|
|
|
for (int i = 0; i < contentPools.length; i++) {
|
|
|
+ int val = i + 1;
|
|
|
if (CollectionUtils.isEmpty(hisPublishedContentMap.get(content.getTitle()))
|
|
|
- || Objects.isNull(indexPublishTimesMap.get(i))) {
|
|
|
+ || Objects.isNull(indexPublishTimesMap.get(val))) {
|
|
|
break;
|
|
|
}
|
|
|
- int val = i;
|
|
|
List<PublishSortLog> filterArticles = hisPublishedContentMap.get(content.getTitle()).stream()
|
|
|
- .filter(o -> (val == 1 && o.getIndex() == 1)||(val == 2 && o.getIndex() == 2)||(val == 3 && o.getIndex() >= 3))
|
|
|
+ .filter(o -> (val == 1 && o.getIndex() == 1) || (val == 2 && o.getIndex() == 2) || (val == 3 && o.getIndex() >= 3))
|
|
|
.collect(Collectors.toList());
|
|
|
if (CollectionUtil.isEmpty(filterArticles)) {
|
|
|
break;
|
|
|
}
|
|
|
if (contentPools[i].equals(content.getContentPoolType())) {
|
|
|
- if (filterArticles.size() >= indexPublishTimesMap.get(i).getTimes()) {
|
|
|
- score.setScore(score.getScore() + indexPublishTimesMap.get(i).getWeight());
|
|
|
+ if (filterArticles.size() >= indexPublishTimesMap.get(val).getTimes()) {
|
|
|
+ score.setScore(score.getScore() + indexPublishTimesMap.get(val).getWeight());
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -76,4 +80,11 @@ public class PublishTimesStrategy implements ScoreStrategy {
|
|
|
return scores;
|
|
|
}
|
|
|
|
|
|
+ public AccountPublishTimesConfig[] getPublishTimes(String accountName) {
|
|
|
+ if (accountPublishTimesConfigMap.containsKey(accountName)) {
|
|
|
+ return accountPublishTimesConfigMap.get(accountName);
|
|
|
+ }
|
|
|
+ return accountPublishTimesConfigMap.get("default");
|
|
|
+ }
|
|
|
+
|
|
|
}
|