Comment out postgres
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
src/main/resources/application.conf
|
||||
src/main/resources/postgres.conf
|
||||
src/main/resources/postgres2.conf
|
||||
|
||||
target/
|
||||
project/target/
|
||||
|
||||
@@ -45,3 +45,9 @@ docker run --name local-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5
|
||||
docker stop local-postgres
|
||||
docker start local-postgres
|
||||
```
|
||||
|
||||
## Fly Postgres
|
||||
```
|
||||
fly machines list --app <app-name>
|
||||
fly machines start <machine-id> --app <app-name>
|
||||
```
|
||||
@@ -8,12 +8,15 @@ import server.Server
|
||||
|
||||
object Main extends IOApp {
|
||||
def run(args: List[String]): IO[ExitCode] = {
|
||||
println(System.getenv("DATABASE_URL"))
|
||||
|
||||
for {
|
||||
transactor <- DBConnection.transactor[IO]
|
||||
postgresService <- PostgresService.of(transactor)
|
||||
_ <- postgresService.createWeatherTable // create table if it does not exists
|
||||
// transactor <- DBConnection.transactor[IO]
|
||||
// postgresService <- PostgresService.of(transactor)
|
||||
// _ <- postgresService.createWeatherTable // create table if it does not exists
|
||||
fileService <- FileService.of
|
||||
dataService <- DataService.of(fileService, postgresService)
|
||||
// dataService <- DataService.of(fileService, postgresService)
|
||||
dataService <- DataService.of(fileService)
|
||||
|
||||
fetch <- FetchService.of
|
||||
fileFetchScheduler <- FileFetchScheduler.of(dataService, fetch)
|
||||
|
||||
@@ -20,7 +20,10 @@ trait DataServiceTrait {
|
||||
}
|
||||
|
||||
object DataService {
|
||||
def of(fileService: FileService, postgresService: PostgresService): IO[DataService] = {
|
||||
def of(
|
||||
fileService: FileService,
|
||||
// postgresService: PostgresService
|
||||
): IO[DataService] = {
|
||||
for {
|
||||
log <- Slf4jLogger.create[IO]
|
||||
fileNameService = new FileNameService()
|
||||
@@ -29,12 +32,13 @@ object DataService {
|
||||
.map(content => (fileName, content)))
|
||||
state = contents.toMap
|
||||
stateRef <- Ref.of[IO, Map[String, List[String]]](state)
|
||||
} yield new DataService(fileService, postgresService, new FileNameService(), log, stateRef)
|
||||
// } yield new DataService(fileService, postgresService, new FileNameService(), log, stateRef)
|
||||
} yield new DataService(fileService, new FileNameService(), log, stateRef)
|
||||
}
|
||||
}
|
||||
class DataService private(
|
||||
fileService: FileService,
|
||||
postgresService: PostgresService,
|
||||
// postgresService: PostgresService,
|
||||
fileNameService: FileNameService,
|
||||
log: Logger[IO],
|
||||
private val state: Ref[IO, Map[String, List[String]]]
|
||||
@@ -52,7 +56,7 @@ class DataService private(
|
||||
|
||||
def save(fileName: String, content: String): IO[String] = {
|
||||
// TODO remove unsafeRunSync
|
||||
postgresService.save(fileName, content).unsafeRunSync()
|
||||
// postgresService.save(fileName, content).unsafeRunSync()
|
||||
|
||||
// TODO delete this
|
||||
fileService.save(fileName, content).redeemWith(
|
||||
@@ -72,8 +76,8 @@ class DataService private(
|
||||
def getDates: IO[List[LocalDate]] = fileService.getDates
|
||||
|
||||
def getDatesByMonths(monthList: List[LocalDate]): IO[List[LocalDate]] = {
|
||||
// fileService.getDatesByMonths(monthList)
|
||||
postgresService.getDatesByMonths(monthList)
|
||||
fileService.getDatesByMonths(monthList)
|
||||
// postgresService.getDatesByMonths(monthList)
|
||||
}
|
||||
|
||||
def getDateFileNames(date: LocalDate): IO[List[String]] = fileService.getDateFileNames(date)
|
||||
|
||||
@@ -15,18 +15,19 @@ object Main {
|
||||
)
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
val xa = transactor[IO]
|
||||
val result = for {
|
||||
postgresService <- PostgresService.of(xa)
|
||||
re <- postgresService.selectWeatherTable
|
||||
} yield re
|
||||
// val xa = transactor[IO]
|
||||
// val result = for {
|
||||
// postgresService <- PostgresService.of(xa)
|
||||
// re <- postgresService.selectWeatherTable
|
||||
// } yield re
|
||||
|
||||
println(System.getenv("DATABASE_URL"))
|
||||
|
||||
// val result = createWeatherTable(xa).unsafeRunSync()
|
||||
// val result = createWeatherTable(xa).unsafeRunSync()
|
||||
// val result = insertInWeatherTable(xa).unsafeRunSync()
|
||||
// val result = selectWeatherTable(xa).unsafeRunSync()
|
||||
// val result = dropWeatherTable(xa).unsafeRunSync()
|
||||
|
||||
println(s"result: ${result.unsafeRunSync()}")
|
||||
// println(s"result: ${result.unsafeRunSync()}")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user