Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont show invalid sbt and scalajs versions #614

Merged
merged 10 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ object ScalaTarget extends Parsers {
tryParse(code, x => scalaTargetParser(x))
}

private val minScalaVersion = SemanticVersion(2, 10)
private val maxScalaVersion = SemanticVersion(2, 13)

def isValidScalaVersion(version: SemanticVersion): Boolean = {
version >= minScalaVersion && version <= maxScalaVersion
}

private def minScalaJsVersion = SemanticVersion(0, 6)

def isValidScalaJsVersion(version: SemanticVersion): Boolean = {
minScalaJsVersion <= version
}

private def minSbtVersion = SemanticVersion(0, 11)
private def maxSbtVersion = SemanticVersion(1, 3)

def isValidSbtVersion(version: SemanticVersion): Boolean = {
minSbtVersion <= version && version <= maxSbtVersion
}

import fastparse.NoWhitespace._
import fastparse._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,28 @@ class DataRepository(paths: DataPaths, githubDownload: GithubDownload)(
}

def getAllScalaVersions(): Future[List[(String, Long)]] = {
versionAggregations("scalaVersion", notDeprecatedQuery, filterScalaVersion)
versionAggregations("scalaVersion",
notDeprecatedQuery,
ScalaTarget.isValidScalaVersion)
}

def getScalaVersions(params: SearchParams): Future[List[(String, Long)]] = {
versionAggregations("scalaVersion",
filteredSearchQuery(params),
filterScalaVersion)
ScalaTarget.isValidScalaVersion)
.map(addLabelsIfMissing(params.scalaVersions.toSet))
}

def getAllScalaJsVersions(): Future[List[(String, Long)]] = {
versionAggregations("scalaJsVersion",
notDeprecatedQuery,
filterScalaJsVersion)
ScalaTarget.isValidScalaJsVersion)
}

def getScalaJsVersions(params: SearchParams): Future[List[(String, Long)]] = {
versionAggregations("scalaJsVersion",
filteredSearchQuery(params),
filterScalaJsVersion)
ScalaTarget.isValidScalaJsVersion)
.map(addLabelsIfMissing(params.scalaJsVersions.toSet))
}

Expand All @@ -258,13 +260,15 @@ class DataRepository(paths: DataPaths, githubDownload: GithubDownload)(
}

def getAllSbtVersions(): Future[List[(String, Long)]] = {
versionAggregations("sbtVersion", notDeprecatedQuery, filterSbtVersion)
versionAggregations("sbtVersion",
notDeprecatedQuery,
ScalaTarget.isValidSbtVersion)
}

def getSbtVersions(params: SearchParams): Future[List[(String, Long)]] = {
versionAggregations("sbtVersion",
filteredSearchQuery(params),
filterSbtVersion)
ScalaTarget.isValidSbtVersion)
.map(addLabelsIfMissing(params.sbtVersions.toSet))
}

Expand Down Expand Up @@ -579,25 +583,6 @@ object DataRepository {
}

private val frontPageCount = 12
private val minScalaVersion = SemanticVersion(2, 10)
private val maxScalaVersion = SemanticVersion(2, 13)

private def filterScalaVersion(version: SemanticVersion): Boolean = {
minScalaVersion <= version && version <= maxScalaVersion
}

private def minSbtVersion = SemanticVersion(0, 11)
private def maxSbtVersion = SemanticVersion(1, 3)

private def filterSbtVersion(version: SemanticVersion): Boolean = {
minSbtVersion <= version && version <= maxSbtVersion
}

private def minScalaJsVersion = SemanticVersion(0, 6)

private def filterScalaJsVersion(version: SemanticVersion): Boolean = {
minScalaJsVersion <= version
}

private def labelizeTargetType(targetType: String): String = {
if (targetType == "JVM") "Scala (Jvm)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ package object html {
}

def sortVersions(versions: Set[String],
scala: Boolean = false): List[String] = {
val minVersion = SemanticVersion(2, 10)
filter: SemanticVersion => Boolean): List[String] = {
versions.toList
.flatMap(SemanticVersion.parse)
.filter(version => !scala || version >= minVersion)
.filter(filter)
.sorted
.map(version => SemanticVersion(version.major, version.minor).toString)
.distinct
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import ch.epfl.scala.index.views.html._
@import ch.epfl.scala.index.model.Project
@import ch.epfl.scala.index.model.release.ScalaTarget
@import ch.epfl.scala.index.model.misc.SearchParams
@(projects: List[Project], params: SearchParams)

Expand All @@ -26,7 +27,7 @@ <h4>@project.reference.organization/@project.reference.repository</h4>
@if(project.scalaVersion.nonEmpty){
<div>
Scala (JVM):
@for(v <- sortVersions(project.scalaVersion, scala = true)) {
@for(v <- sortVersions(project.scalaVersion, ScalaTarget.isValidScalaVersion)) {
<span class="targets">@v</span>
}
</div>
Expand All @@ -35,7 +36,7 @@ <h4>@project.reference.organization/@project.reference.repository</h4>
@if(project.sbtVersion.nonEmpty){
<div>
Sbt:
@for(v <- sortVersions(project.sbtVersion)) {
@for(v <- sortVersions(project.sbtVersion, ScalaTarget.isValidSbtVersion)) {
<span class="targets">@v</span>
}
</div>
Expand All @@ -44,7 +45,7 @@ <h4>@project.reference.organization/@project.reference.repository</h4>
@if(project.scalaJsVersion.nonEmpty){
<div>
Scala.js:
@for(v <- sortVersions(project.scalaJsVersion)) {
@for(v <- sortVersions(project.scalaJsVersion, ScalaTarget.isValidScalaJsVersion)) {
<span class="targets">@v</span>
}
</div>
Expand All @@ -53,7 +54,7 @@ <h4>@project.reference.organization/@project.reference.repository</h4>
@if(project.scalaNativeVersion.nonEmpty){
<div>
Scala-Native:
@for(v <- sortVersions(project.scalaNativeVersion)) {
@for(v <- sortVersions(project.scalaNativeVersion, _ => true)) {
adpi2 marked this conversation as resolved.
Show resolved Hide resolved
<span class="targets">@v</span>
}
</div>
Expand Down