-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
48 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
modules/server/src/main/scala/scaladex/server/service/Metrics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package scaladex.server.service | ||
|
||
import scala.concurrent.ExecutionContext | ||
import scala.concurrent.Future | ||
|
||
import cats.implicits.toTraverseOps | ||
import com.typesafe.scalalogging.LazyLogging | ||
import scaladex.infra.SqlDatabase | ||
|
||
class Metrics(db: SqlDatabase)(implicit ec: ExecutionContext) extends LazyLogging { | ||
def run(): Future[String] = { | ||
val years: Seq[Int] = Range.inclusive(2013, 2022) | ||
for { | ||
countByYear <- years.traverse(db.countProjects) | ||
projects <- db.getAllProjects() | ||
} yield { | ||
years.zip(countByYear).foreach { case (year, count) => logger.info(s"$year: $count") } | ||
val filteredProjects = projects.filter(p => !p.githubStatus.isMoved && !p.githubStatus.isNotFound) | ||
logger.info(s"total projects: ${filteredProjects.size}") | ||
val contributors = filteredProjects.flatMap(_.githubInfo).flatMap(_.contributors).map(_.login).distinct.size | ||
logger.info(s"total contributors: $contributors") | ||
"Success" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
server/src/main/scala/scaladex/server/service/Metrics.scala
This file was deleted.
Oops, something went wrong.