From 46b7a9b01b50fa418f82d83b421b513f73550d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Wed, 16 Jun 2021 18:04:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E6=AC=A1=E6=80=A7=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.Scanner/GithubContextStatistics.cs | 3 ++- FastGithub.Scanner/Middlewares/StatisticsMiddleware.cs | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FastGithub.Scanner/GithubContextStatistics.cs b/FastGithub.Scanner/GithubContextStatistics.cs index f151fd3..9df0788 100644 --- a/FastGithub.Scanner/GithubContextStatistics.cs +++ b/FastGithub.Scanner/GithubContextStatistics.cs @@ -21,13 +21,14 @@ namespace FastGithub.Scanner public TimeSpan TotalSuccessElapsed { get; private set; } - public void SetScan() + public void SetScanFailure() { this.TotalScanCount += 1; } public void SetScanSuccess(TimeSpan elapsed) { + this.TotalScanCount += 1; this.TotalSuccessCount += 1; this.TotalSuccessElapsed = this.TotalSuccessElapsed.Add(elapsed); } diff --git a/FastGithub.Scanner/Middlewares/StatisticsMiddleware.cs b/FastGithub.Scanner/Middlewares/StatisticsMiddleware.cs index ed2bfcb..2aecd10 100644 --- a/FastGithub.Scanner/Middlewares/StatisticsMiddleware.cs +++ b/FastGithub.Scanner/Middlewares/StatisticsMiddleware.cs @@ -14,16 +14,19 @@ namespace FastGithub.Scanner.Middlewares try { stopwatch.Start(); - context.Statistics.SetScan(); await next(); } finally { stopwatch.Stop(); - if (context.Available == true) + if (context.Available) { context.Statistics.SetScanSuccess(stopwatch.Elapsed); } + else + { + context.Statistics.SetScanFailure(); + } } } }