Skip to content

Commit

Permalink
Fix DeepSource CS-W1091
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Oct 7, 2023
1 parent 4058e6c commit 4e59b6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Controllers/BiliVideoInfoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public BiliVideoInfoController(ILogger<BiliVideoInfoController> logger, IHttpCli
using var hc = _httpClientFactory.CreateClient("Timeout5s");
hc.BaseAddress = new("https://api.bilibili.com/x/web-interface/view");
try {
var start = DateTime.Now;
var start = DateTime.UtcNow;
info = await hc.GetFromJsonAsync<BiliVideoInfo>(queryString).ConfigureAwait(false);
Response.Headers.Add("Server-Timing", $"g;desc=\"Get API\";dur={(DateTime.Now - start).TotalMilliseconds}"); // Server Timing API
Response.Headers.Add("Server-Timing", $"g;desc=\"Get API\";dur={(DateTime.UtcNow - start).TotalMilliseconds}"); // Server Timing API

using var entry = _memoryCache.CreateEntry(cacheKey); // 写入内存缓存
entry.Value = info;
Expand Down
4 changes: 2 additions & 2 deletions Controllers/BingImageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public BingImageController(ILogger<BingImageController> logger, IHttpClientFacto
using var hc = _httpClientFactory.CreateClient("Timeout5s");
hc.BaseAddress = new("https://cn.bing.com/HPImageArchive.aspx");
try {
var start = DateTime.Now;
var start = DateTime.UtcNow;
var result = await hc.GetFromJsonAsync<BingAPIRoot>($"?format=js&n={count}&idx={_id}").ConfigureAwait(false);
Response.Headers.Add("Server-Timing", $"g;desc=\"Get API\";dur={(DateTime.Now - start).TotalMilliseconds}"); // Server Timing API
Response.Headers.Add("Server-Timing", $"g;desc=\"Get API\";dur={(DateTime.UtcNow - start).TotalMilliseconds}"); // Server Timing API
return result;
} catch (HttpRequestException e) {
_logger.LogCritical("在连接服务器时发生异常:{}", e);
Expand Down

0 comments on commit 4e59b6f

Please sign in to comment.