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