@@ -37,10 +37,6 @@ public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous,
3737 {
3838 log . LogInformation ( $ "{ nameof ( GetMicrosoftLearnContributors ) } Started") ;
3939
40- var timeSpan = to - from ;
41- if ( timeSpan . TotalDays > 365 )
42- return new BadRequestObjectResult ( $ "Invalid Timespan: { timeSpan . TotalDays } days. Timespan must be less than 365 days") ;
43-
4440 var cancellationTokenSource = new CancellationTokenSource ( TimeSpan . FromSeconds ( 2 ) ) ;
4541 var gitHubApiStatus = await _gitHubApiStatusService . GetApiRateLimits ( cancellationTokenSource . Token ) . ConfigureAwait ( false ) ;
4642 if ( gitHubApiStatus . GraphQLApi . RemainingRequestCount < 4000 )
@@ -71,7 +67,7 @@ public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous,
7167 var cloudAdvocateContributions = new List < GitHubContributorModel > ( ) ;
7268 foreach ( var cloudAdvocate in cloudAdvocateList )
7369 {
74- var cloudAdvocateContributorModel = new GitHubContributorModel ( microsoftLearnPullRequests . Where ( x => x . Author . Equals ( cloudAdvocate . GitHubUserName , StringComparison . OrdinalIgnoreCase ) ) , cloudAdvocate ) ;
70+ var cloudAdvocateContributorModel = new GitHubContributorModel ( microsoftLearnPullRequests . Where ( x => x . Author . Equals ( cloudAdvocate . GitHubUserName , StringComparison . OrdinalIgnoreCase ) && x . CreatedAt . IsWithinRange ( from , to ) ) , cloudAdvocate ) ;
7571
7672 cloudAdvocateContributions . Add ( cloudAdvocateContributorModel ) ;
7773
@@ -81,4 +77,9 @@ public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous,
8177 return new OkObjectResult ( cloudAdvocateContributions ) ;
8278 }
8379 }
80+
81+ static class DateTimeExtensions
82+ {
83+ public static bool IsWithinRange ( this DateTimeOffset dateTimeOffset , DateTimeOffset start , DateTimeOffset end ) => dateTimeOffset >= start && dateTimeOffset <= end ;
84+ }
8485}
0 commit comments