Add postgres host to .env, filter out sum values for country
This commit is contained in:
@@ -12,9 +12,10 @@ object DBConnection {
|
|||||||
private def getDbName = sys.env.getOrElse("POSTGRES_DB", "")
|
private def getDbName = sys.env.getOrElse("POSTGRES_DB", "")
|
||||||
private def getDbUser = sys.env.getOrElse("POSTGRES_USER", "")
|
private def getDbUser = sys.env.getOrElse("POSTGRES_USER", "")
|
||||||
private def getDbPassword = sys.env.getOrElse("POSTGRES_PASSWORD", "")
|
private def getDbPassword = sys.env.getOrElse("POSTGRES_PASSWORD", "")
|
||||||
|
private def getDbHost = sys.env.getOrElse("POSTGRES_HOST", "")
|
||||||
|
|
||||||
private def getDatabaseUrl: String =
|
private def getDatabaseUrl: String =
|
||||||
sys.env.getOrElse("DATABASE_URL", s"postgres://${getDbUser}:${getDbPassword}@postgres:5432/${getDbName}") // host - postgres for docker, 0.0.0.0 outside docker
|
sys.env.getOrElse("DATABASE_URL", s"postgres://${getDbUser}:${getDbPassword}@${getDbHost}:5432/${getDbName}") // host - postgres for docker, 0.0.0.0 outside docker
|
||||||
|
|
||||||
private def parseUrl(url: String): Either[String, PostgresConfig] = {
|
private def parseUrl(url: String): Either[String, PostgresConfig] = {
|
||||||
Try {
|
Try {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import { apiHost } from './consts';
|
|||||||
console.log("env:", import.meta.env.MODE);
|
console.log("env:", import.meta.env.MODE);
|
||||||
console.log("api host:", apiHost);
|
console.log("api host:", apiHost);
|
||||||
|
|
||||||
// type Section = "station" | "cities" | "country" | "database";
|
|
||||||
|
|
||||||
const App: Component = () => {
|
const App: Component = () => {
|
||||||
const pages: [string, () => JSXElement][] = [
|
const pages: [string, () => JSXElement][] = [
|
||||||
["station", () => <Station />],
|
["station", () => <Station />],
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export const Result: Component<{
|
|||||||
}> = ({ result: resultResource }) => {
|
}> = ({ result: resultResource }) => {
|
||||||
const countryData = () => Object.entries(resultResource()!)
|
const countryData = () => Object.entries(resultResource()!)
|
||||||
.sort((a, b) => a[0] > b[0] ? 1 : -1)
|
.sort((a, b) => a[0] > b[0] ? 1 : -1)
|
||||||
|
.map(filterOutSums)
|
||||||
.map(([field, values]) => <tr>
|
.map(([field, values]) => <tr>
|
||||||
<td>{field}</td>
|
<td>{field}</td>
|
||||||
<td>{values[0]}</td>
|
<td>{values[0]}</td>
|
||||||
@@ -31,4 +32,15 @@ export const Result: Component<{
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type CountryFieldValues = [number | undefined, number | undefined, number | undefined, number | undefined];
|
||||||
|
|
||||||
|
const sumFields = ["precipitation", "snowAvg", "sunDuration"];
|
||||||
|
|
||||||
|
function filterOutSums([field, values]: [string, CountryFieldValues]): [string, CountryFieldValues] {
|
||||||
|
const modifiedValues: CountryFieldValues = [...values];
|
||||||
|
if (!sumFields.includes(field)) modifiedValues[3] = undefined;
|
||||||
|
|
||||||
|
return [field, modifiedValues];
|
||||||
}
|
}
|
||||||
@@ -41,4 +41,16 @@ thead {
|
|||||||
|
|
||||||
.primary:hover {
|
.primary:hover {
|
||||||
background-color: #ffb92d;
|
background-color: #ffb92d;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td {
|
||||||
|
padding: 3px 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:nth-child(odd) {
|
||||||
|
background: #d6d6d6;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:hover {
|
||||||
|
background: #c0c0c0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user