-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add statistics control table, fix cellName in some statistics, improv…
…e docker support, remove test web server (#125) * Recreate docker compose so it handles the database * Update other instructions according to the new docker approach * Add statistics control table * Save error message when generating statistics * Save statistics control status * Update docker compose version to the next one (make github actions happy) * Fix oldest standing record query * Run tests in random port * Do not rely on the test web server anymore, mock it instead * Fix tests * Avoid downloading database again if not needed
- Loading branch information
Showing
29 changed files
with
348 additions
and
2,976 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,41 @@ | ||
version: "3.7" | ||
version: "3.8" | ||
|
||
services: | ||
server: | ||
build: | ||
context: server | ||
dockerfile: Dockerfile | ||
network_mode: host | ||
mysql: | ||
image: mysql:8.0 | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: "true" | ||
MYSQL_DATABASE: wca_development | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
|
||
client: | ||
build: | ||
context: client | ||
dockerfile: Dockerfile | ||
db_restore: | ||
image: ubuntu:20.04 | ||
depends_on: | ||
- server | ||
network_mode: host | ||
- mysql | ||
entrypoint: > | ||
sh -c " | ||
apt update && apt install curl unzip mysql-client wget -y && | ||
result=$(mysql -h mysql -sN -u root -e 'use wca_development; select datediff(now(), max(results_posted_at)) from Competitions;' || echo 999) && | ||
echo 'Days since last update: ' $result && | ||
if [ -n \"$result\" ] && [ $result -lt 7 ]; then | ||
echo 'Database is already up to date, skipping restoration.' | ||
exit 0 | ||
else | ||
echo 'Database is outdated, restoring...' | ||
fi && | ||
echo 'Downloading WCA database dump, this may take a while...' && | ||
wget -q https://www.worldcubeassociation.org/wst/wca-developer-database-dump.zip && | ||
rm -rf wca-developer-database-dump.sql && | ||
unzip wca-developer-database-dump.zip && | ||
echo 'Restoring WCA database. This also may take a while...' && | ||
mysql -h mysql -u root -e 'drop database if exists wca_development; create database wca_development; use wca_development; source wca-developer-database-dump.sql;' && | ||
echo 'Restoration complete!' | ||
" | ||
volumes: | ||
- mysql-data:/var/lib/mysql | ||
|
||
volumes: | ||
mysql-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
version: "3.1" | ||
services: | ||
wca-test-db: | ||
image: "mysql:8.0.26" | ||
image: mysql:8.0 | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: "true" | ||
MYSQL_DATABASE: wca_development | ||
ports: | ||
- "3307:3306" | ||
volumes: | ||
- "./db/migration:/docker-entrypoint-initdb.d/:ro" | ||
wca-mock-server: | ||
image: "node:16-bullseye-slim" | ||
volumes: | ||
- "./test-web-server/data.js/:/data.js" | ||
- "./test-web-server/package.json/:/package.json" | ||
- "./test-web-server/server.js/:/server.js" | ||
entrypoint: sh -c "npm install;npm start" | ||
network_mode: host | ||
- wca-test-db-data:/var/lib/mysql | ||
|
||
volumes: | ||
wca-test-db-data: |
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
14 changes: 14 additions & 0 deletions
14
server/src/main/java/org/worldcubeassociation/statistics/config/RestTemplateConfig.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,14 @@ | ||
package org.worldcubeassociation.statistics.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Configuration | ||
public class RestTemplateConfig { | ||
|
||
@Bean | ||
public RestTemplate restTemplate() { | ||
return new RestTemplate(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
server/src/main/java/org/worldcubeassociation/statistics/enums/StatisticsControlStatus.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,7 @@ | ||
package org.worldcubeassociation.statistics.enums; | ||
|
||
public enum StatisticsControlStatus { | ||
STARTED, | ||
COMPLETED, | ||
FAILED | ||
} |
37 changes: 37 additions & 0 deletions
37
server/src/main/java/org/worldcubeassociation/statistics/model/StatisticsControl.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,37 @@ | ||
package org.worldcubeassociation.statistics.model; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hibernate.annotations.Type; | ||
import org.worldcubeassociation.statistics.dto.StatisticsGroupResponseDTO; | ||
import org.worldcubeassociation.statistics.enums.DisplayModeEnum; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@EqualsAndHashCode(callSuper = true) | ||
@Table(name = "statistics_control") | ||
public class StatisticsControl extends BaseEntity { | ||
@Id | ||
private String path; | ||
|
||
private String message; | ||
|
||
private String status; | ||
|
||
@Column(name = "created_at") | ||
private LocalDateTime createdAt; | ||
|
||
@Column(name = "completed_at") | ||
private LocalDateTime completedAt; | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/org/worldcubeassociation/statistics/repository/StatisticsControlRepository.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 org.worldcubeassociation.statistics.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import org.worldcubeassociation.statistics.model.StatisticsControl; | ||
|
||
@Repository | ||
public interface StatisticsControlRepository extends JpaRepository<StatisticsControl, String> { | ||
|
||
} |
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
Oops, something went wrong.