This commit is contained in:
tanglong 2025-07-15 11:23:01 +08:00
parent 7974cd115e
commit 03901ceb06

View File

@ -212,11 +212,14 @@ namespace YD_AllHeartRates.Api.Services.Impl
int total = RedisHelper.Keys("heartRate:*").Length;
res.WarmUp = total == 0 ? 0 : (int)Math.Round(warmUp * 100.0 / total);
res.Low = total == 0 ? 0 : (int)Math.Round(low * 100.0 / total);
res.Medium = total == 0 ? 0 : (int)Math.Round(medium * 100.0 / total);
res.High = total == 0 ? 0 : (int)Math.Round(high * 100.0 / total);
res.Warning = total == 0 ? 0 : (int)Math.Round(warning * 100.0 / total);
int CalcPercentage(int count) =>
total == 0 ? 0 : (int)Math.Round(count * 100.0 / total);
res.WarmUp = CalcPercentage(warmUp);
res.Low = CalcPercentage(low);
res.Medium = CalcPercentage(medium);
res.High = CalcPercentage(high);
res.Warning = CalcPercentage(warning);
return res;
}