-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PP-893: keep a history of latest seven day averages
- Loading branch information
Showing
19 changed files
with
415 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3.1' | ||
|
||
services: | ||
|
||
dpppt-additionalinfo_db: | ||
image: postgres:11 | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: dpppt | ||
POSTGRES_DB: dpppt-additionalinfo | ||
POSTGRES_USER: dpppt | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- dpppt-additionalinfo_db_data:/var/lib/postgresql/data | ||
volumes: | ||
dpppt-additionalinfo_db_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...o-backend/src/main/java/org/dpppt/additionalinfo/backend/ws/config/WSCloudBaseConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package org.dpppt.additionalinfo.backend.ws.config; | ||
|
||
import java.util.Map; | ||
import javax.sql.DataSource; | ||
import org.flywaydb.core.Flyway; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.cloud.CloudFactory; | ||
import org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig; | ||
import org.springframework.cloud.service.relational.DataSourceConfig; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public abstract class WSCloudBaseConfig extends WSBaseConfig { | ||
|
||
abstract String getPublicKey(); | ||
|
||
abstract String getPrivateKey(); | ||
|
||
@Value("${datasource.maximumPoolSize:5}") | ||
int dataSourceMaximumPoolSize; | ||
|
||
@Value("${datasource.connectionTimeout:30000}") | ||
int dataSourceConnectionTimeout; | ||
|
||
@Value("${datasource.leakDetectionThreshold:0}") | ||
int dataSourceLeakDetectionThreshold; | ||
|
||
@Bean | ||
@Override | ||
public DataSource dataSource() { | ||
PoolConfig poolConfig = | ||
new PoolConfig(dataSourceMaximumPoolSize, dataSourceConnectionTimeout); | ||
DataSourceConfig dbConfig = | ||
new DataSourceConfig( | ||
poolConfig, | ||
null, | ||
null, | ||
Map.of("leakDetectionThreshold", dataSourceLeakDetectionThreshold)); | ||
CloudFactory factory = new CloudFactory(); | ||
return factory.getCloud().getSingletonServiceConnector(DataSource.class, dbConfig); | ||
} | ||
|
||
@Bean("flyway") | ||
@Override | ||
public Flyway flyway() { | ||
Flyway flyWay = | ||
Flyway.configure() | ||
.dataSource(dataSource()) | ||
.locations("classpath:/db/migration/pgsql_cluster") | ||
.load(); | ||
flyWay.migrate(); | ||
return flyWay; | ||
} | ||
|
||
@Override | ||
public String getDbType() { | ||
return "pgsql"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...fo-backend/src/main/java/org/dpppt/additionalinfo/backend/ws/data/HistoryDataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
* | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
|
||
package org.dpppt.additionalinfo.backend.ws.data; | ||
|
||
import java.time.LocalDate; | ||
|
||
public interface HistoryDataService { | ||
|
||
/** | ||
* upserts the latest seven day average for the given day | ||
* | ||
* @param latestSevenDayAvg | ||
* @param day | ||
*/ | ||
void upsertLatestSevenDayAvgForDay(Integer latestSevenDayAvg, LocalDate day); | ||
|
||
/** | ||
* returns the latest seven day average for the given day | ||
* @param day | ||
* @return | ||
*/ | ||
Integer findLatestSevenDayAvgForDay(LocalDate day); | ||
} |
Oops, something went wrong.