-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
246 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,12 @@ | ||
root = true | ||
|
||
[*] | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
charset = utf-8 | ||
indent_style = space | ||
end_of_line = lf | ||
indent_size = 2 | ||
|
||
[*.java] | ||
indent_size = 4 |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
# Predictr | ||
|
||
A football prediction game. | ||
A football prediction game. | ||
Data for UEFA Euro 2024 included. | ||
|
||
## Run locally | ||
|
||
``` | ||
./mvnw mn:run | ||
``` | ||
./start-db.sh # Database | ||
./mvnw mn:run # Application | ||
``` |
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,16 @@ | ||
services: | ||
db: | ||
image: postgres:16.2-alpine | ||
restart: always | ||
shm_size: 128mb | ||
environment: | ||
POSTGRES_USER: predictr | ||
POSTGRES_PASSWORD: s3cret | ||
POSTGRES_DB: predictr | ||
ports: | ||
- 5432:5432 | ||
adminer: | ||
image: adminer:4.8.1-standalone | ||
restart: always | ||
ports: | ||
- 9000:8080 |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/de/meonwax/predictr/controller/ConfigController.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,25 @@ | ||
package de.meonwax.predictr.controller; | ||
|
||
import de.meonwax.predictr.entity.Config; | ||
import de.meonwax.predictr.repository.ConfigRepository; | ||
import io.micronaut.http.annotation.Controller; | ||
import io.micronaut.http.annotation.Get; | ||
|
||
import java.util.Optional; | ||
|
||
@Controller("/config") | ||
public class ConfigController { | ||
|
||
private final ConfigRepository configRepository; | ||
|
||
ConfigController(ConfigRepository configRepository) { | ||
this.configRepository = configRepository; | ||
} | ||
|
||
@Get | ||
Optional<Config> index() { | ||
return configRepository.findAll() | ||
.stream() | ||
.findFirst(); | ||
} | ||
} |
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,22 @@ | ||
package de.meonwax.predictr.entity; | ||
|
||
import io.micronaut.core.annotation.Nullable; | ||
import io.micronaut.data.annotation.Id; | ||
import io.micronaut.data.annotation.MappedEntity; | ||
import io.micronaut.serde.annotation.Serdeable; | ||
|
||
@MappedEntity | ||
@Serdeable | ||
public record Config( | ||
@Id Long id, | ||
String title, | ||
String owner, | ||
String adminEmail, | ||
Boolean showImportantMessage, | ||
Integer pointsResult, | ||
Integer pointsTendency, | ||
Integer pointsTendencySpread, | ||
@Nullable String rulesEn, | ||
@Nullable String rulesDe | ||
) { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/de/meonwax/predictr/repository/ConfigRepository.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,10 @@ | ||
package de.meonwax.predictr.repository; | ||
|
||
import de.meonwax.predictr.entity.Config; | ||
import io.micronaut.data.jdbc.annotation.JdbcRepository; | ||
import io.micronaut.data.model.query.builder.sql.Dialect; | ||
import io.micronaut.data.repository.CrudRepository; | ||
|
||
@JdbcRepository(dialect = Dialect.POSTGRES) | ||
public interface ConfigRepository extends CrudRepository<Config, Long> { | ||
} |
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
micronaut: | ||
application: | ||
name: predictr | ||
server: | ||
port: 8081 | ||
|
||
datasources: | ||
default: | ||
url: jdbc:postgresql://localhost:5432/predictr | ||
username: predictr | ||
password: s3cret | ||
driverClassName: org.postgresql.Driver | ||
dialect: POSTGRES | ||
schema-generate: NONE | ||
|
||
liquibase: | ||
enabled: true | ||
datasources: | ||
default: | ||
change-log: 'classpath:db/liquibase-changelog.xml' |
39 changes: 39 additions & 0 deletions
39
src/main/resources/db/changelog/01-create-config-schema.xml
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,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> | ||
|
||
<changeSet id="01" author="meonwax"> | ||
<createTable tableName="config"> | ||
<column name="id" type="bigserial"> | ||
<constraints nullable="false" unique="true" primaryKey="true"/> | ||
</column> | ||
<column name="title" type="varchar(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="owner" type="varchar(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="admin_email" type="varchar(255)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="show_important_message" type="boolean"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="points_result" type="int"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="points_tendency" type="int"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="points_tendency_spread" type="int"> | ||
<constraints nullable="false"/> | ||
</column> | ||
<column name="rules_en" type="text"/> | ||
<column name="rules_de" type="text"/> | ||
</createTable> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> | ||
|
||
<changeSet id="02" author="meonwax"> | ||
<insert tableName="config"> | ||
<column name="title">Predictr</column> | ||
<column name="owner">John Doe</column> | ||
<column name="admin_email">[email protected]</column> | ||
<column name="show_important_message">true</column> | ||
<column name="points_result">5</column> | ||
<column name="points_tendency">2</column> | ||
<column name="points_tendency_spread">3</column> | ||
</insert> | ||
</changeSet> | ||
|
||
</databaseChangeLog> |
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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd"> | ||
<include file="changelog/01-create-config-schema.xml" relativeToChangelogFile="true"/> | ||
<include file="changelog/02-insert-config.xml" relativeToChangelogFile="true"/> | ||
</databaseChangeLog> |
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,6 @@ | ||
|
||
▄▄▄·▄▄▄ ▄▄▄ .·▄▄▄▄ ▪ ▄▄· ▄▄▄▄▄▄▄▄ | ||
▐█ ▄█▀▄ █·▀▄.▀·██▪ ██ ██ ▐█ ▌▪•██ ▀▄ █· | ||
██▀·▐▀▀▄ ▐▀▀▪▄▐█· ▐█▌▐█·██ ▄▄ ▐█.▪▐▀▀▄ | ||
▐█▪·•▐█•█▌▐█▄▄▌██. ██ ▐█▌▐███▌ ▐█▌·▐█•█▌ | ||
.▀ .▀ ▀ ▀▀▀ ▀▀▀▀▀• ▀▀▀·▀▀▀ ▀▀▀ .▀ ▀ |
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,7 @@ | ||
#!/bin/bash | ||
set -eu | ||
cleanup() { | ||
docker compose -f docker-compose-database.yml rm -fsv | ||
} | ||
trap cleanup EXIT | ||
docker compose -f docker-compose-database.yml up |