@@ -8,6 +8,7 @@ import scala.concurrent.Future
8
8
9
9
import cats .effect .IO
10
10
import com .typesafe .scalalogging .LazyLogging
11
+ import com .zaxxer .hikari .HikariDataSource
11
12
import doobie .implicits ._
12
13
import scaladex .core .model .Artifact
13
14
import scaladex .core .model .ArtifactDependency
@@ -16,21 +17,22 @@ import scaladex.core.model.GithubResponse
16
17
import scaladex .core .model .GithubStatus
17
18
import scaladex .core .model .Project
18
19
import scaladex .core .model .ProjectDependency
20
+ import scaladex .core .model .ReleaseDependency
19
21
import scaladex .core .model .UserState
20
22
import scaladex .core .service .SchedulerDatabase
21
- import scaladex .infra .config .PostgreSQLConfig
22
23
import scaladex .infra .sql .ArtifactDependencyTable
23
24
import scaladex .infra .sql .ArtifactTable
24
25
import scaladex .infra .sql .DoobieUtils
25
26
import scaladex .infra .sql .GithubInfoTable
26
27
import scaladex .infra .sql .ProjectDependenciesTable
27
28
import scaladex .infra .sql .ProjectSettingsTable
28
29
import scaladex .infra .sql .ProjectTable
30
+ import scaladex .infra .sql .ReleaseDependenciesTable
31
+ import scaladex .infra .sql .ReleaseTable
29
32
import scaladex .infra .sql .UserSessionsTable
30
33
31
- class SqlDatabase (conf : PostgreSQLConfig , xa : doobie.Transactor [IO ]) extends SchedulerDatabase with LazyLogging {
32
-
33
- private val flyway = DoobieUtils .flyway(conf)
34
+ class SqlDatabase (datasource : HikariDataSource , xa : doobie.Transactor [IO ]) extends SchedulerDatabase with LazyLogging {
35
+ private val flyway = DoobieUtils .flyway(datasource)
34
36
def migrate : IO [Unit ] = IO (flyway.migrate())
35
37
def dropTables : IO [Unit ] = IO (flyway.clean())
36
38
@@ -43,6 +45,7 @@ class SqlDatabase(conf: PostgreSQLConfig, xa: doobie.Transactor[IO]) extends Sch
43
45
for {
44
46
isNewProject <- insertProjectRef(artifact.projectRef, unknownStatus)
45
47
_ <- run(ArtifactTable .insertIfNotExist.run(artifact))
48
+ _ <- run(ReleaseTable .insertIfNotExists.run(artifact.release))
46
49
_ <- insertDependencies(dependencies)
47
50
} yield isNewProject
48
51
}
@@ -166,9 +169,15 @@ class SqlDatabase(conf: PostgreSQLConfig, xa: doobie.Transactor[IO]) extends Sch
166
169
override def computeProjectDependencies (): Future [Seq [ProjectDependency ]] =
167
170
run(ArtifactDependencyTable .computeProjectDependency.to[Seq ])
168
171
172
+ override def computeReleaseDependencies (): Future [Seq [ReleaseDependency ]] =
173
+ run(ArtifactDependencyTable .computeReleaseDependency.to[Seq ])
174
+
169
175
override def insertProjectDependencies (projectDependencies : Seq [ProjectDependency ]): Future [Int ] =
170
176
run(ProjectDependenciesTable .insertOrUpdate.updateMany(projectDependencies))
171
177
178
+ override def insertReleaseDependencies (releaseDependency : Seq [ReleaseDependency ]): Future [Int ] =
179
+ run(ReleaseDependenciesTable .insertIfNotExists.updateMany(releaseDependency))
180
+
172
181
override def countInverseProjectDependencies (projectRef : Project .Reference ): Future [Int ] =
173
182
run(ProjectDependenciesTable .countInverseDependencies.unique(projectRef))
174
183
0 commit comments