Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Commit e2007c1

Browse files
authored
Merge pull request #82 from USST-JavaWeb-251-AdFlux/feature/my-new-change
refactor(adfluxbackend): 优化广告推荐算法和调试功能
2 parents f9ad186 + 4d18e6f commit e2007c1

3 files changed

Lines changed: 3 additions & 5 deletions

File tree

src/main/java/com/usst/adfluxbackend/aop/AdDebugAspect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class AdDebugAspect {
1616

1717
private final ObjectMapper objectMapper = new ObjectMapper();
1818

19-
// 拦截你的 selectAdForSlot 方法,或者拦截 Controller 层
19+
// 拦截selectAdForSlot 方法
2020
@Around("execution(* com.usst.adfluxbackend.service.impl.TrackerServiceImpl.selectAdForSlot(..))")
2121
public Object captureCalculation(ProceedingJoinPoint joinPoint) throws Throwable {
2222

src/main/java/com/usst/adfluxbackend/service/impl/TrackerServiceImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ private boolean isWeeklyBudgetExceeded(Long adId, BigDecimal weeklyBudget, Map<S
256256

257257
/**
258258
* 根据用户历史行为计算分类权重
259-
* 对应原来的 calculateCategoryWeights
260259
*/
261260
private Map<Long, Double> calculateCategoryWeights(String trackId, Set<Long> categoryIds) {
262261
Map<Long, Double> weights = new HashMap<>();
@@ -283,10 +282,10 @@ private Map<Long, Double> calculateCategoryWeights(String trackId, Set<Long> cat
283282
int totalDuration = categoryDurationMap.values().stream().mapToInt(Integer::intValue).sum();
284283

285284
// 为每个分类添加少量虚拟时长,避免单条数据导致权重为1
286-
int smoothingFactor = 5; // 每个分类虚拟5秒
285+
int smoothingFactor = 15; // 每个分类虚拟15秒
287286
int smoothedTotal = totalDuration + smoothingFactor * categoryIds.size();
288287

289-
double baseScore = 0.2; // 基础分
288+
double baseScore = 0.2; // 基础权重
290289
for (Long categoryId : categoryIds) {
291290
int actualDuration = categoryDurationMap.getOrDefault(categoryId, 0);
292291
// 平滑后的历史分数

src/main/java/com/usst/adfluxbackend/websocket/AdDebugWebSocket.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public static void sendDebugInfo(String message) {
4444
} catch (IOException e) {
4545
e.printStackTrace();
4646
} catch (IllegalStateException e) {
47-
// 防止极端的并发导致状态异常,捕获它以免影响主业务
4847
System.err.println("WS发送忙: " + e.getMessage());
4948
}
5049
}

0 commit comments

Comments
 (0)