diff --git a/build.sbt b/build.sbt index e82282a36..98aadb711 100644 --- a/build.sbt +++ b/build.sbt @@ -23,7 +23,7 @@ lazy val loggingSettings = Seq( "com.typesafe.scala-logging" %% "scala-logging" % "3.9.5" ), // Drop and replace commons-logging with slf4j - libraryDependencies += "org.slf4j" % "jcl-over-slf4j" % "2.0.13", + libraryDependencies += "org.slf4j" % "jcl-over-slf4j" % "2.0.16", excludeDependencies += ExclusionRule("commons-logging", "commons-logging") ) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala index 3968a3160..d10b54765 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala @@ -48,9 +48,6 @@ case class Artifact( s"$groupId$sep$artifactName" } - def release: Release = - Release(projectRef.organization, projectRef.repository, platform, language, version, releaseDate) - def releaseDateFormat: String = Artifact.dateFormatter.format(releaseDate) def httpUrl: String = { diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Release.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Release.scala deleted file mode 100644 index 71120f43e..000000000 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Release.scala +++ /dev/null @@ -1,14 +0,0 @@ -package scaladex.core.model - -import java.time.Instant - -import scaladex.core.model.Project._ - -case class Release( - organization: Organization, - repository: Repository, - platform: Platform, - language: Language, - version: SemanticVersion, - releaseDate: Instant -) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/ReleaseDependency.scala b/modules/core/shared/src/main/scala/scaladex/core/model/ReleaseDependency.scala deleted file mode 100644 index 60ca2a76b..000000000 --- a/modules/core/shared/src/main/scala/scaladex/core/model/ReleaseDependency.scala +++ /dev/null @@ -1,13 +0,0 @@ -package scaladex.core.model - -import scaladex.core.model.ArtifactDependency.Scope - -case class ReleaseDependency( - source: Release, - target: Release, - scope: Scope -) -object ReleaseDependency { - case class Direct(targetRef: Project.Reference, targetVersion: SemanticVersion, scope: Scope) - case class Reverse(sourceRef: Project.Reference, targetVersion: SemanticVersion, scope: Scope) -} diff --git a/modules/core/shared/src/main/scala/scaladex/core/service/SchedulerDatabase.scala b/modules/core/shared/src/main/scala/scaladex/core/service/SchedulerDatabase.scala index 80d751b18..2dee10e16 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/service/SchedulerDatabase.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/service/SchedulerDatabase.scala @@ -9,7 +9,6 @@ import scaladex.core.model.Artifact.MavenReference import scaladex.core.model.ArtifactDependency import scaladex.core.model.Project import scaladex.core.model.ProjectDependency -import scaladex.core.model.ReleaseDependency import scaladex.core.model.SemanticVersion trait SchedulerDatabase extends WebDatabase { @@ -18,11 +17,9 @@ trait SchedulerDatabase extends WebDatabase { def updateProjectCreationDate(ref: Project.Reference, creationDate: Instant): Future[Unit] def computeAllProjectsCreationDates(): Future[Seq[(Instant, Project.Reference)]] - // project dependencies (and release dependencies) + // project dependencies def computeProjectDependencies(reference: Project.Reference, version: SemanticVersion): Future[Seq[ProjectDependency]] - def computeReleaseDependencies(): Future[Seq[ReleaseDependency]] def insertProjectDependencies(projectDependencies: Seq[ProjectDependency]): Future[Int] - def insertReleaseDependencies(projectDependencies: Seq[ReleaseDependency]): Future[Int] def deleteProjectDependencies(ref: Project.Reference): Future[Int] // artifacts and its dependencies diff --git a/modules/core/shared/src/main/scala/scaladex/core/service/WebDatabase.scala b/modules/core/shared/src/main/scala/scaladex/core/service/WebDatabase.scala index 6e5401a58..2abaac473 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/service/WebDatabase.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/service/WebDatabase.scala @@ -6,7 +6,6 @@ import java.util.UUID import scala.concurrent.Future import scaladex.core.model._ -import scaladex.core.web.ArtifactsPageParams trait WebDatabase { // artifacts @@ -14,11 +13,7 @@ trait WebDatabase { def insertArtifact(artifact: Artifact, dependencies: Seq[ArtifactDependency], time: Instant): Future[Boolean] def getArtifacts(groupId: Artifact.GroupId, artifactId: Artifact.ArtifactId): Future[Seq[Artifact]] def getArtifacts(projectRef: Project.Reference): Future[Seq[Artifact]] - def getArtifacts( - ref: Project.Reference, - artifactName: Artifact.Name, - params: ArtifactsPageParams - ): Future[Seq[Artifact]] + def getArtifacts(ref: Project.Reference, artifactName: Artifact.Name, preReleases: Boolean): Future[Seq[Artifact]] def getArtifacts(ref: Project.Reference, artifactName: Artifact.Name, version: SemanticVersion): Future[Seq[Artifact]] def getArtifactsByName(projectRef: Project.Reference, artifactName: Artifact.Name): Future[Seq[Artifact]] def getLatestArtifacts(ref: Project.Reference, preferStableVersions: Boolean): Future[Seq[Artifact]] diff --git a/modules/core/shared/src/test/scala/scaladex/core/test/InMemoryDatabase.scala b/modules/core/shared/src/test/scala/scaladex/core/test/InMemoryDatabase.scala index 26cdceb9a..b0a4d4327 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/test/InMemoryDatabase.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/test/InMemoryDatabase.scala @@ -14,12 +14,10 @@ import scaladex.core.model.Language import scaladex.core.model.Platform import scaladex.core.model.Project import scaladex.core.model.ProjectDependency -import scaladex.core.model.ReleaseDependency import scaladex.core.model.SemanticVersion import scaladex.core.model.UserInfo import scaladex.core.model.UserState import scaladex.core.service.SchedulerDatabase -import scaladex.core.web.ArtifactsPageParams class InMemoryDatabase extends SchedulerDatabase { private val allProjects = mutable.Map[Project.Reference, Project]() @@ -125,7 +123,6 @@ class InMemoryDatabase extends SchedulerDatabase { ref: Project.Reference, version: SemanticVersion ): Future[Seq[ProjectDependency]] = ??? - override def computeReleaseDependencies(): Future[Seq[ReleaseDependency]] = ??? override def computeAllProjectsCreationDates(): Future[Seq[(Instant, Project.Reference)]] = ??? @@ -134,8 +131,6 @@ class InMemoryDatabase extends SchedulerDatabase { override def insertProjectDependencies(projectDependencies: Seq[ProjectDependency]): Future[Int] = ??? - override def insertReleaseDependencies(releaseDependency: Seq[ReleaseDependency]): Future[Int] = ??? - override def countProjectDependents(ref: Project.Reference): Future[Long] = Future.successful(0) @@ -161,9 +156,9 @@ class InMemoryDatabase extends SchedulerDatabase { override def getArtifacts( ref: Project.Reference, artifactName: Artifact.Name, - params: ArtifactsPageParams + preReleases: Boolean ): Future[Seq[Artifact]] = - // does not filter with params + // TODO: use preReleases to filter Future.successful(allArtifacts.getOrElse(ref, Seq.empty).filter(_.artifactName == artifactName)) override def getProjectDependencies( ref: Project.Reference, diff --git a/modules/infra/src/main/resources/migrations/V21__drop_release_and_release_dependencies.sql b/modules/infra/src/main/resources/migrations/V21__drop_release_and_release_dependencies.sql new file mode 100644 index 000000000..33c69a7e1 --- /dev/null +++ b/modules/infra/src/main/resources/migrations/V21__drop_release_and_release_dependencies.sql @@ -0,0 +1,2 @@ +DROP TABLE releases, release_dependencies; + diff --git a/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala b/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala index 59af19dcd..412625137 100644 --- a/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala +++ b/modules/infra/src/main/scala/scaladex/infra/SqlDatabase.scala @@ -18,12 +18,10 @@ import scaladex.core.model.Language import scaladex.core.model.Platform import scaladex.core.model.Project import scaladex.core.model.ProjectDependency -import scaladex.core.model.ReleaseDependency import scaladex.core.model.SemanticVersion import scaladex.core.model.UserInfo import scaladex.core.model.UserState import scaladex.core.service.SchedulerDatabase -import scaladex.core.web.ArtifactsPageParams import scaladex.infra.sql.ArtifactDependencyTable import scaladex.infra.sql.ArtifactTable import scaladex.infra.sql.DoobieUtils @@ -31,13 +29,14 @@ import scaladex.infra.sql.GithubInfoTable import scaladex.infra.sql.ProjectDependenciesTable import scaladex.infra.sql.ProjectSettingsTable import scaladex.infra.sql.ProjectTable -import scaladex.infra.sql.ReleaseDependenciesTable -import scaladex.infra.sql.ReleaseTable import scaladex.infra.sql.UserSessionsTable class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) extends SchedulerDatabase with LazyLogging { private val flyway = DoobieUtils.flyway(datasource) - def migrate: IO[Unit] = IO(flyway.migrate()) + def migrate: IO[Unit] = IO { + flyway.repair() + flyway.migrate() + } def dropTables: IO[Unit] = IO(flyway.clean()) override def insertArtifact( @@ -49,7 +48,6 @@ class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) exten for { isNewProject <- insertProjectRef(artifact.projectRef, unknownStatus) _ <- run(ArtifactTable.insertIfNotExist(artifact)) - _ <- run(ReleaseTable.insertIfNotExists.run(artifact.release)) _ <- insertDependencies(dependencies) } yield isNewProject } @@ -180,9 +178,6 @@ class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) exten ): Future[Seq[ProjectDependency]] = run(ArtifactDependencyTable.computeProjectDependencies.to[Seq]((ref, version))) - override def computeReleaseDependencies(): Future[Seq[ReleaseDependency]] = - run(ArtifactDependencyTable.computeReleaseDependency.to[Seq]) - override def insertProjectDependencies(projectDependencies: Seq[ProjectDependency]): Future[Int] = if (projectDependencies.isEmpty) Future.successful(0) else run(ProjectDependenciesTable.insertOrUpdate.updateMany(projectDependencies)) @@ -190,9 +185,6 @@ class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) exten override def deleteProjectDependencies(ref: Project.Reference): Future[Int] = run(ProjectDependenciesTable.deleteBySource.run(ref)) - override def insertReleaseDependencies(releaseDependency: Seq[ReleaseDependency]): Future[Int] = - run(ReleaseDependenciesTable.insertIfNotExists.updateMany(releaseDependency)) - override def countProjectDependents(projectRef: Project.Reference): Future[Long] = run(ProjectDependenciesTable.countDependents.unique(projectRef)) @@ -235,13 +227,9 @@ class SqlDatabase(datasource: HikariDataSource, xa: doobie.Transactor[IO]) exten override def getArtifacts( ref: Project.Reference, artifactName: Artifact.Name, - params: ArtifactsPageParams + preReleases: Boolean ): Future[Seq[Artifact]] = - run( - ArtifactTable - .selectArtifactByParams(params.binaryVersions, params.preReleases) - .to[Seq](ref, artifactName) - ) + run(ArtifactTable.selectArtifactByParams(preReleases).to[Seq](ref, artifactName)) override def countVersions(ref: Project.Reference): Future[Long] = run(ArtifactTable.countVersionsByProject.unique(ref)) diff --git a/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala b/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala deleted file mode 100644 index a69c246cd..000000000 --- a/modules/infra/src/main/scala/scaladex/infra/migrations/V11_2__add_data_to_the_new_tables.scala +++ /dev/null @@ -1,24 +0,0 @@ -package scaladex.infra.migrations - -import com.typesafe.scalalogging.LazyLogging -import org.flywaydb.core.api.migration.BaseJavaMigration -import org.flywaydb.core.api.migration.Context -import scaladex.infra.sql.ArtifactTable -import scaladex.infra.sql.ReleaseTable - -class V11_2__add_data_to_the_new_tables extends BaseJavaMigration with ScaladexBaseMigration with LazyLogging { - override def migrate(context: Context): Unit = - try { - (for { - releases <- run(xa)(ArtifactTable.getReleasesFromArtifacts.to[Seq]) - _ <- run(xa)(ReleaseTable.insertIfNotExists.updateMany(releases)) - } yield ()) - .unsafeRunSync() - - } catch { - case e: Throwable => - logger.info("failed to migrate the database") - throw new Exception(s"failed to migrate the database because of ${e.getMessage}") - } - -} diff --git a/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactDependencyTable.scala b/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactDependencyTable.scala index 6ae2a5e7f..db4193de5 100644 --- a/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactDependencyTable.scala +++ b/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactDependencyTable.scala @@ -6,7 +6,6 @@ import scaladex.core.model.Artifact import scaladex.core.model.ArtifactDependency import scaladex.core.model.Project import scaladex.core.model.ProjectDependency -import scaladex.core.model.ReleaseDependency import scaladex.core.model.SemanticVersion import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils._ @@ -74,16 +73,6 @@ object ArtifactDependencyTable { Seq("d.organization", "d.repository", "d.version", "t.organization", "t.repository", "t.version", "d.scope") ).contramap { case (ref, version) => (ref, version, ref) } - val computeReleaseDependency: Query0[ReleaseDependency] = { - val sourceReleaseFields = ReleaseTable.primaryKeys.map("d." + _) - val targetReleaseFields = ReleaseTable.primaryKeys.map("t." + _) - selectRequest( - fullJoin, - sourceReleaseFields ++ Seq("MIN(d.release_date)") ++ targetReleaseFields ++ Seq("MIN(t.release_date)", "d.scope"), - groupBy = (sourceReleaseFields ++ targetReleaseFields) ++ Seq("d.scope") - ) - } - val selectDependencyFromProject: Query[Project.Reference, ArtifactDependency] = selectRequest( tableWithSourceArtifact, diff --git a/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactTable.scala b/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactTable.scala index 051527545..a1a10dc47 100644 --- a/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactTable.scala +++ b/modules/infra/src/main/scala/scaladex/infra/sql/ArtifactTable.scala @@ -5,11 +5,9 @@ import java.time.Instant import doobie._ import doobie.util.update.Update import scaladex.core.model.Artifact -import scaladex.core.model.BinaryVersion import scaladex.core.model.Language import scaladex.core.model.Platform import scaladex.core.model.Project -import scaladex.core.model.Release import scaladex.core.model.SemanticVersion import scaladex.infra.sql.DoobieUtils.Mappings._ import scaladex.infra.sql.DoobieUtils._ @@ -86,21 +84,12 @@ object ArtifactTable { where = Seq("organization=?", "repository=?", "artifact_name=?", "version=?") ) - def selectArtifactByParams( - binaryVersions: Seq[BinaryVersion], - preReleases: Boolean - ): Query[(Project.Reference, Artifact.Name), Artifact] = { - val binaryVersionFilter = - if (binaryVersions.isEmpty) "true" - else - binaryVersions - .map(bv => s"(platform='${bv.platform.label}' AND language_version='${bv.language.label}')") - .mkString("(", " OR ", ")") - val preReleaseFilter = if (preReleases) s"true" else "is_prerelease=false" + def selectArtifactByParams(preReleases: Boolean): Query[(Project.Reference, Artifact.Name), Artifact] = { + val preReleaseFilter = if (preReleases) "true" else "is_prerelease=false" Query[(Project.Reference, Artifact.Name), Artifact]( s"""|SELECT ${fields.mkString(", ")} - |FROM $table WHERE - |organization=? AND repository=? AND artifact_name=? AND $binaryVersionFilter AND $preReleaseFilter + |FROM $table + |WHERE organization=? AND repository=? AND artifact_name=? AND $preReleaseFilter |""".stripMargin ) } @@ -128,13 +117,6 @@ object ArtifactTable { groupBy = projectReferenceFields ) - val getReleasesFromArtifacts: Query0[Release] = - selectRequest( - table, - Seq("organization", "repository", "platform", "language_version", "version", "MIN(release_date)"), - groupBy = Seq("organization", "repository ", "platform ", "language_version", "version") - ) - def selectLatestArtifacts(stableOnly: Boolean): Query[Project.Reference, Artifact] = selectRequest1(latestDateTable(stableOnly), fields.map(c => s"a.$c")) diff --git a/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseDependenciesTable.scala b/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseDependenciesTable.scala deleted file mode 100644 index c5e009123..000000000 --- a/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseDependenciesTable.scala +++ /dev/null @@ -1,36 +0,0 @@ -package scaladex.infra.sql - -import doobie.util.update.Update -import scaladex.core.model.ReleaseDependency -import scaladex.infra.sql.DoobieUtils.Mappings._ -import scaladex.infra.sql.DoobieUtils.insertOrUpdateRequest - -object ReleaseDependenciesTable { - private val table: String = "release_dependencies" - private val sourcePrimaryKeys: Seq[String] = - Seq( - "source_organization", - "source_repository", - "source_platform", - "source_language_version", - "source_version" - ) - private val targetPrimaryKeys: Seq[String] = - Seq( - "target_organization", - "target_repository", - "target_platform", - "target_language_version", - "target_version" - ) - - val scope = "scope" - val sourceKeys: Seq[String] = sourcePrimaryKeys :+ "source_release_date" - val targetKeys: Seq[String] = targetPrimaryKeys :+ "target_release_date" - private val primaryKeys = (sourcePrimaryKeys ++ targetPrimaryKeys) :+ scope - - private val fields: Seq[String] = (sourceKeys ++ targetKeys) :+ scope - - val insertIfNotExists: Update[ReleaseDependency] = - insertOrUpdateRequest(table, fields, primaryKeys) -} diff --git a/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseTable.scala b/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseTable.scala deleted file mode 100644 index aebf5c9e8..000000000 --- a/modules/infra/src/main/scala/scaladex/infra/sql/ReleaseTable.scala +++ /dev/null @@ -1,23 +0,0 @@ -package scaladex.infra.sql -import doobie.util.update.Update -import scaladex.core.model.Release -import scaladex.infra.sql.DoobieUtils.Mappings._ -import scaladex.infra.sql.DoobieUtils.insertOrUpdateRequest - -object ReleaseTable { - private val table: String = "releases" - val primaryKeys: Seq[String] = - Seq( - "organization", - "repository", - "platform", - "language_version", - "version" - ) - private val fields: Seq[String] = - primaryKeys ++ Seq( - "release_date" - ) - val insertIfNotExists: Update[Release] = - insertOrUpdateRequest(table, fields, primaryKeys) -} diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala index 051596714..00c261546 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactDependencyTableTests.scala @@ -11,5 +11,4 @@ class ArtifactDependencyTableTests extends AnyFunSpec with BaseDatabaseSuite wit it("check selectDirectDependency")(check(ArtifactDependencyTable.selectDirectDependency)) it("check selectReverseDependency")(check(ArtifactDependencyTable.selectReverseDependency)) it("check computeProjectDependencies")(check(ArtifactDependencyTable.computeProjectDependencies)) - it("check computeReleaseDependency")(check(ArtifactDependencyTable.computeReleaseDependency)) } diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala index 5af529486..440553416 100644 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/sql/ArtifactTableTests.scala @@ -5,7 +5,6 @@ import org.scalatest.matchers.should.Matchers import scaladex.core.model.Jvm import scaladex.core.model.Scala import scaladex.core.model.ScalaJs -import scaladex.core.test.Values._ import scaladex.infra.BaseDatabaseSuite class ArtifactTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { @@ -26,12 +25,10 @@ class ArtifactTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers it("check selectMavenReference")(check(selectMavenReference)) it("check updateReleaseDate")(check(updateReleaseDate)) it("check selectByMavenReference")(check(selectByMavenReference)) - it("check getReleasesFromArtifacts")(check(getReleasesFromArtifacts)) it("check countVersionsByProject")(check(countVersionsByProject)) it("check selectArtifactByParams") { - check(selectArtifactByParams(Seq.empty, false)) - check(selectArtifactByParams(Seq.empty, true)) - check(selectArtifactByParams(Seq(`_sjs0.6_2.13`), false)) + check(selectArtifactByParams(false)) + check(selectArtifactByParams(true)) } it("check selectMavenReferenceWithNoReleaseDate")(check(selectMavenReferenceWithNoReleaseDate)) it("check selectLatestArtifacts") { diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala deleted file mode 100644 index a57beb4b7..000000000 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseDependenciesTableTests.scala +++ /dev/null @@ -1,9 +0,0 @@ -package scaladex.infra.sql - -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite - -class ReleaseDependenciesTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { - it("check insertIfNotExists")(check(ReleaseDependenciesTable.insertIfNotExists)) -} diff --git a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala b/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala deleted file mode 100644 index 3ef958076..000000000 --- a/modules/infra/src/test/scala/scaladex/infra/sql/ReleaseTableTests.scala +++ /dev/null @@ -1,9 +0,0 @@ -package scaladex.infra.sql - -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers -import scaladex.infra.BaseDatabaseSuite - -class ReleaseTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers { - it("check insertIfNotExists")(check(ReleaseTable.insertIfNotExists)) -} diff --git a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala index 2ac124001..35ee95295 100644 --- a/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala +++ b/modules/server/src/main/scala/scaladex/server/route/ProjectPages.scala @@ -41,7 +41,7 @@ class ProjectPages(env: Env, database: WebDatabase, searchEngine: SearchEngine)( path(projectM / "artifacts" / artifactNameM) { (ref, artifactName) => artifactsParams { params => getProjectOrRedirect(ref, user) { project => - val artifactsF = database.getArtifacts(ref, artifactName, params) + val artifactsF = database.getArtifacts(ref, artifactName, params.preReleases) val headerF = service.getProjectHeader(project).map(_.get) for (artifacts <- artifactsF; header <- headerF) yield { val binaryVersions = artifacts diff --git a/modules/server/src/main/scala/scaladex/server/service/DependencyUpdater.scala b/modules/server/src/main/scala/scaladex/server/service/DependencyUpdater.scala index 253d35fdb..9f2a17ac2 100644 --- a/modules/server/src/main/scala/scaladex/server/service/DependencyUpdater.scala +++ b/modules/server/src/main/scala/scaladex/server/service/DependencyUpdater.scala @@ -15,7 +15,6 @@ class DependencyUpdater(database: SchedulerDatabase)(implicit ec: ExecutionConte def updateAll(): Future[String] = for { status <- updateProjectDependencyTable() - _ <- updateReleaseDependencyTable() } yield status def updateProjectDependencyTable(): Future[String] = @@ -50,29 +49,4 @@ class DependencyUpdater(database: SchedulerDatabase)(implicit ec: ExecutionConte logger.error(s"Failed to update dependencies of ${project.reference} of status ${project.githubStatus}", cause) } } - - def updateReleaseDependencyTable(): Future[Unit] = - for { - releaseDependencies <- database - .computeReleaseDependencies() - .mapFailure(e => - new Exception( - s"Failed to compute release dependencies because of ${e.getMessage}" - ) - ) - _ = logger.info(s"will try to insert ${releaseDependencies.size} releaseDependencies") - _ <- releaseDependencies - .grouped(10000) - .map(releaseDependencies => - database - .insertReleaseDependencies(releaseDependencies) - .mapFailure(e => - new Exception( - s"Failed to insert release dependencies because of ${e.getMessage}" - ) - ) - ) - .sequence - - } yield () }