mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-13 20:46:38 +08:00
优化
This commit is contained in:
@@ -836,9 +836,6 @@ UPDATE \`statistics_flow\`
|
||||
SET \`created_time\` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE \`created_time\` = 0 OR \`created_time\` IS NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
# 检查数据库容器
|
||||
|
||||
@@ -37,11 +37,11 @@ public class StatisticsFlowAsync {
|
||||
long time = new Date().getTime();
|
||||
|
||||
// 删除48小时前的数据
|
||||
long nowMs = System.currentTimeMillis();
|
||||
long nowMs = new Date().getTime();
|
||||
long cutoffMs = nowMs - 48L * 60 * 60 * 1000;
|
||||
statisticsFlowService.remove(
|
||||
new LambdaQueryWrapper<StatisticsFlow>()
|
||||
.lt(StatisticsFlow::getCreateTime, cutoffMs)
|
||||
.lt(StatisticsFlow::getCreatedTime, cutoffMs)
|
||||
);
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class StatisticsFlowAsync {
|
||||
statisticsFlow.setFlow(incrementFlow);
|
||||
statisticsFlow.setTotalFlow(currentTotalFlow);
|
||||
statisticsFlow.setTime(hourString);
|
||||
statisticsFlow.setCreateTime(time);
|
||||
statisticsFlow.setCreatedTime(time);
|
||||
|
||||
statisticsFlowList.add(statisticsFlow);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class StatisticsFlow {
|
||||
|
||||
private String time;
|
||||
|
||||
private Long createTime;
|
||||
private Long createdTime;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -727,7 +727,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
* @return 最近24小时流量统计列表
|
||||
*/
|
||||
private List<StatisticsFlow> getLast24HoursFlowStatistics(Long userId) {
|
||||
try {
|
||||
// 按ID倒序查最近24条记录(ID越大越新,时间就是23:00, 22:00, 21:00...这样倒序)
|
||||
List<StatisticsFlow> recentFlows = statisticsFlowService.list(
|
||||
new QueryWrapper<StatisticsFlow>()
|
||||
@@ -766,11 +765,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
log.debug("用户 {} 获取到 {} 条实际记录,补齐为 {} 条24小时记录", userId, recentFlows.size(), result.size());
|
||||
return result;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("获取用户 {} 最近24小时流量统计失败", userId, e);
|
||||
// 返回24条全0数据,时间从当前小时往前推
|
||||
return generateEmpty24HourData(userId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -215,7 +215,7 @@ export default function IndexPage() {
|
||||
const checkResponse = await checkCaptcha();
|
||||
|
||||
if (checkResponse.code !== 0) {
|
||||
toast.error("检查验证码状态失败,请重试");
|
||||
toast.error("检查验证码状态失败,请重试" + checkResponse.msg);
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ export default function IndexPage() {
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('检查验证码状态错误:', error);
|
||||
toast.error("网络错误,请稍后重试");
|
||||
toast.error("网络错误,请稍后重试" + error);
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user