Skip to content

Commit

Permalink
Merge pull request #816 from adpi2/naming-810
Browse files Browse the repository at this point in the history
Some renaming from #810
  • Loading branch information
adpi2 authored Jan 12, 2022
2 parents 21d316e + 59b419d commit cd52567
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ trait SchedulerDatabase extends WebDatabase {
def updateProjectCreationDate(ref: Project.Reference, creationDate: Instant): Future[Unit]
def insertProjectDependencies(projectDependencies: Seq[ProjectDependency]): Future[Int]
def countInverseProjectDependencies(projectRef: Project.Reference): Future[Int]
def deleteMovedProjectFromProjectDependencyTable(): Future[Unit]
def deleteDependenciesOfMovedProject(): Future[Unit]
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ class PlatformTests extends AsyncFunSpec with Matchers with OptionValues with Ta
PlatformType.ofName("Js").value shouldBe PlatformType.Js
PlatformType.ofName("Jvm").value shouldBe PlatformType.Jvm
}
it("Should encode and parse a ScalaTarget") {
val st = ScalaJs(ScalaVersion.`2.10`, MinorBinary(0, 6))
println(s"st.encode = ${st.encode}")
assert(parse(st.encode).get == st)
it("Should encode and parse a Scala.js platform") {
val platform = ScalaJs(ScalaVersion.`2.10`, MinorBinary(0, 6))
assert(parse(platform.encode).get == platform)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ class InMemoryDatabase extends SchedulerDatabase {
override def countInverseProjectDependencies(projectRef: Project.Reference): Future[Int] = ???

override def updataArtifacts(artifacts: Seq[Artifact], newRef: Project.Reference): Future[Int] = ???
override def deleteMovedProjectFromProjectDependencyTable(): scala.concurrent.Future[Unit] = ???
override def deleteDependenciesOfMovedProject(): scala.concurrent.Future[Unit] = ???
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ class SqlDatabase(conf: DatabaseConfig, xa: doobie.Transactor[IO]) extends Sched
override def countInverseProjectDependencies(projectRef: Project.Reference): Future[Int] =
run(ProjectDependenciesTable.countInverseDependencies.unique(projectRef))

override def deleteMovedProjectFromProjectDependencyTable(): Future[Unit] =
override def deleteDependenciesOfMovedProject(): Future[Unit] =
for {
moved <- run(ProjectTable.selectProjectByGithubStatus.to[List]("Moved"))
_ <- run(ProjectDependenciesTable.deleteSourceProject.updateMany(moved))
_ <- run(ProjectDependenciesTable.deleteTargetProject.updateMany(moved))
_ <- run(ProjectDependenciesTable.deleteBySource.updateMany(moved))
_ <- run(ProjectDependenciesTable.deleteByTarget.updateMany(moved))
} yield ()

override def computeAllProjectsCreationDates(): Future[Seq[(Instant, Project.Reference)]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ object ProjectDependenciesTable {
val countInverseDependencies: Query[Project.Reference, Int] =
selectRequest(table, Seq("COUNT(*)"), targetFields)

val deleteSourceProject: Update[Project.Reference] =
val deleteBySource: Update[Project.Reference] =
deleteRequest(table, sourceFields)

val deleteTargetProject: Update[Project.Reference] =
val deleteByTarget: Update[Project.Reference] =
deleteRequest(table, targetFields)

}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class SqlDatabaseTests extends AsyncFunSpec with BaseDatabaseSuite with Matchers
Scalafix.githubInfo,
GithubStatus.Moved(now, Project.Reference.from("scala", "fix"))
)
_ <- database.deleteMovedProjectFromProjectDependencyTable()
_ <- database.deleteDependenciesOfMovedProject()
scalafixInverseDeps <- database.countInverseProjectDependencies(Scalafix.reference)
catsInverseDeps <- database.countInverseProjectDependencies(Cats.reference)
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import scaladex.infra.storage.sql.tables.ProjectDependenciesTable

class ProjectDependenciesTableTests extends AnyFunSpec with BaseDatabaseSuite with Matchers {
it("check insertOrUpdate")(check(ProjectDependenciesTable.insertOrUpdate))
it("check deleteSourceProject")(check(ProjectDependenciesTable.deleteSourceProject))
it("check deleteBySource")(check(ProjectDependenciesTable.deleteBySource))
it("check deleteByTarget")(check(ProjectDependenciesTable.deleteByTarget))
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ class SchedulerService(database: SchedulerDatabase, searchEngine: SearchEngine,
.computeProjectDependencies()
.mapFailure(e =>
new Exception(
s"not able to getAllProjectDependencies because of ${e.getMessage}"
s"Failed to compute project dependencies because of ${e.getMessage}"
)
)
_ = println(s" I m here!")
_ <- database.deleteMovedProjectFromProjectDependencyTable()
_ <- database.deleteDependenciesOfMovedProject()
_ <- database
.insertProjectDependencies(projectWithDependencies)
.mapFailure(e =>
new Exception(
s"not able to insertProjectDependencies because of ${e.getMessage}"
s"Failed to insert project dependencies because of ${e.getMessage}"
)
)

Expand Down

0 comments on commit cd52567

Please sign in to comment.