This commit is contained in:
tanglong 2025-07-15 13:39:28 +08:00
parent 4d4ff11ee9
commit e813d22174

View File

@ -154,28 +154,28 @@ namespace YD_AllHeartRates.Api.Services.Impl
var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey); var jumpRope = _caching.Get<JumpRopeData>(jumpRopeKey);
// ❗心率缓存未命中 → 单独查数据库 // ❗心率缓存未命中 → 单独查数据库
if (heartRate == null) //if (heartRate == null)
{ //{
heartRate = await _userContext.HeartRateData // heartRate = await _userContext.HeartRateData
.Where(x => x.StudentNo == student.StudentNo && x.ScoreTime >= tenMinutesAgo) // .Where(x => x.StudentNo == student.StudentNo && x.ScoreTime >= tenMinutesAgo)
.OrderByDescending(x => x.ScoreTime) // .OrderByDescending(x => x.ScoreTime)
.FirstOrDefaultAsync(); // .FirstOrDefaultAsync();
//if (heartRate != null) // //if (heartRate != null)
// _caching.AddObject(heartRateKey, heartRate, 60); // // _caching.AddObject(heartRateKey, heartRate, 60);
} //}
// ❗跳绳缓存未命中 → 单独查数据库 // ❗跳绳缓存未命中 → 单独查数据库
if (jumpRope == null) //if (jumpRope == null)
{ //{
jumpRope = await _userContext.JumpRopeData // jumpRope = await _userContext.JumpRopeData
.Where(x => x.StudentNo == student.StudentNo && x.ScoreTime.Date == now.Date) // .Where(x => x.StudentNo == student.StudentNo && x.ScoreTime.Date == now.Date)
.OrderByDescending(x => x.ScoreTime) // .OrderByDescending(x => x.ScoreTime)
.FirstOrDefaultAsync(); // .FirstOrDefaultAsync();
//if (jumpRope != null) // //if (jumpRope != null)
// _caching.AddObject(jumpRopeKey, jumpRope, 60); // // _caching.AddObject(jumpRopeKey, jumpRope, 60);
} //}
// 心率强度判断 // 心率强度判断
int strength = heartRate?.Strength ?? 0; int strength = heartRate?.Strength ?? 0;