def fetchMergedPullRequests()

in app/lib/RepoSnapshot.scala [98:113]


    def fetchMergedPullRequests()(implicit repo: Repo): Future[Seq[PRSnapshot]] = {
      val now = ZonedDateTime.now()
      val timeThresholdForScan = now.minus(WorthyOfScanWindow)

      def isNewEnoughToBeWorthScanning(pr: PullRequest) = pr.merged_at.exists(_.isAfter(timeThresholdForScan))

      (for {
        litePullRequests: Seq[PullRequest] <-
          repo.pullRequests.list(ClosedPRsMostlyRecentlyUpdated).take(2).all(): Future[Seq[PullRequest]]
        pullRequests <-
          Future.traverse(litePullRequests.filter(isMergedToMain).filter(isNewEnoughToBeWorthScanning).take(MaxPRsToScanPerRepo))(pr => prSnapshot(pr.number))
      } yield {
        log(s"PRs merged to master size=${pullRequests.size}")
        pullRequests
      }) andThen { case cprs => log(s"Merged Pull Requests fetched: ${cprs.map(_.map(_.pr.number).sorted.reverse)}") }
    }