Skip to content

Commit 9693b46

Browse files
authored
Merge pull request #113 from SM-Obstacle/111-rework-graphql-pagination
Rework graphql pagination
2 parents e7eb02d + 8ac19e4 commit 9693b46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+7085
-1969
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
sudo mariadb -e "FLUSH PRIVILEGES";
4242
4343
- name: Setup Rust
44-
uses: dtolnay/rust-toolchain@1.89.0
44+
uses: dtolnay/rust-toolchain@1.92.0
4545

4646
- name: Configure cache
4747
uses: Swatinem/rust-cache@v2
@@ -50,7 +50,8 @@ jobs:
5050
env:
5151
DATABASE_URL: mysql://api:${{ secrets.MARIADB_PW }}@localhost:3306/master_db
5252
REDIS_URL: redis://localhost:6379
53-
run: RUST_BACKTRACE=1 cargo test -F mysql -F test
53+
GQL_API_CURSOR_SECRET_KEY: ${{ secrets.GQL_API_CURSOR_SECRET_KEY }}
54+
run: RUST_BACKTRACE=1 cargo test -F mysql
5455

5556
lint:
5657
name: Lint
@@ -61,13 +62,16 @@ jobs:
6162
uses: actions/checkout@v4
6263

6364
- name: Setup Rust
64-
uses: dtolnay/rust-toolchain@1.89.0
65+
uses: dtolnay/rust-toolchain@1.92.0
6566

6667
- name: Setup Clippy
6768
run: rustup component add clippy
6869

6970
- name: Run clippy
7071
run: |
71-
cargo clippy --no-default-features -- -D warnings
72-
cargo clippy -- -D warnings
72+
cargo clippy --no-default-features -F mysql -- -D warnings
73+
cargo clippy -r --no-default-features -F mysql -- -D warnings
74+
cargo clippy -F mysql -- -D warnings
75+
cargo clippy -r -F mysql -- -D warnings
7376
cargo clippy --all-features -- -D warnings
77+
cargo clippy -r --all-features -- -D warnings

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Checkout repository
1818
uses: actions/checkout@v4
1919
- name: Setup Rust
20-
uses: dtolnay/rust-toolchain@1.89.0
20+
uses: dtolnay/rust-toolchain@1.92.0
2121
- name: Configure cache
2222
uses: Swatinem/rust-cache@v2
2323
- name: Setup pages
@@ -26,7 +26,7 @@ jobs:
2626
- name: Clean docs folder
2727
run: cargo clean --doc
2828
- name: Build docs
29-
run: cargo +nightly doc --all-features --no-deps --workspace --exclude clear_redis_mappacks --exclude admin
29+
run: cargo +nightly doc --all-features --no-deps --workspace --exclude admin
3030
- name: Add redirect
3131
run: echo '<meta http-equiv="refresh" content="0;url=records_lib/index.html">' > target/doc/index.html
3232
- name: Remove lock file

Cargo.toml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,41 @@ members = [
1313
"crates/graphql-schema-generator",
1414
"crates/player-map-ranking",
1515
"crates/compute-player-map-ranking",
16+
"crates/test-env",
1617
]
1718

1819
[workspace.dependencies]
19-
thiserror = "2.0.12"
20-
tokio = "1.44.1"
21-
async-graphql = "7.0.15"
22-
sqlx = { version = "0.8.3", features = ["chrono", "mysql", "runtime-tokio"] }
23-
chrono = { version = "0.4.40", features = ["serde"] }
24-
deadpool = { version = "0.12.2", features = ["managed", "rt_tokio_1"] }
20+
thiserror = "2.0.17"
21+
tokio = "1.49.0"
22+
async-graphql = "7.1.0"
23+
sqlx = { version = "0.8.6", features = ["chrono", "mysql", "runtime-tokio"] }
24+
chrono = { version = "0.4.42", features = ["serde"] }
25+
deadpool = { version = "0.12.3", features = ["managed", "rt_tokio_1"] }
2526
deadpool-redis = { version = "0.20.0", features = ["rt_tokio_1"] }
26-
serde = "1.0.219"
27-
tracing = "0.1.41"
28-
tracing-subscriber = "0.3.19"
29-
actix-web = "4.10.2"
27+
serde = "1.0.228"
28+
tracing = "0.1.44"
29+
tracing-subscriber = "0.3.22"
30+
actix-web = "4.12.1"
3031
actix-cors = "0.7.1"
31-
async-graphql-actix-web = "7.0.15"
32-
tracing-actix-web = "0.7.16"
33-
reqwest = { version = "0.12.14", features = ["json"] }
34-
rand = "0.9.0"
35-
futures = "0.3.27"
32+
async-graphql-actix-web = "7.1.0"
33+
tracing-actix-web = "0.7.20"
34+
reqwest = { version = "0.12.28", features = ["json"] }
35+
rand = "0.9.2"
36+
futures = "0.3.31"
3637
sha256 = "1.6.0"
3738
actix-session = { version = "0.10.1", features = ["cookie-session"] }
38-
anyhow = "1.0.97"
39+
anyhow = "1.0.100"
3940
dotenvy = "0.15.7"
4041
itertools = "0.14.0"
41-
once_cell = "1.21.1"
42-
csv = "1.3.0"
43-
mkenv = "0.1.6"
42+
once_cell = "1.21.3"
43+
csv = "1.4.0"
44+
mkenv = "1.0.2"
4445
nom = "8.0.0"
4546
pin-project-lite = "0.2.16"
46-
sea-orm = { version = "1.1.14", features = [
47+
sea-orm = { version = "1.1.19", features = [
4748
"runtime-tokio",
4849
"macros",
4950
"with-chrono",
5051
] }
51-
serde_json = "1.0.143"
52+
serde_json = "1.0.149"
5253
prettytable = { version = "0.10.0", default-features = false }

crates/admin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
anyhow = { workspace = true }
8-
clap = { version = "4.5.16", features = ["derive"] }
8+
clap = { version = "4.5.54", features = ["derive"] }
99
csv = { workspace = true }
1010
deadpool-redis = { workspace = true }
1111
dotenvy = { workspace = true }

crates/admin/src/main.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clap::Parser;
2-
use mkenv::Env as _;
2+
use mkenv::prelude::*;
33
use records_lib::{Database, DbEnv, LibEnv};
44

55
use self::{clear::ClearCommand, leaderboard::LbCommand, populate::PopulateCommand};
@@ -24,7 +24,12 @@ enum EventCommand {
2424
Clear(ClearCommand),
2525
}
2626

27-
mkenv::make_env!(Env includes [DbEnv as db_env, LibEnv as lib_env]:);
27+
mkenv::make_config! {
28+
struct Env {
29+
db_env: { DbEnv },
30+
lib_env: { LibEnv },
31+
}
32+
}
2833

2934
#[tokio::main]
3035
async fn main() -> anyhow::Result<()> {
@@ -33,11 +38,15 @@ async fn main() -> anyhow::Result<()> {
3338
.compact()
3439
.try_init()
3540
.map_err(|e| anyhow::anyhow!("unable to init tracing_subscriber: {e}"))?;
36-
let env = Env::try_get()?;
41+
let env = Env::define();
42+
env.init();
3743
records_lib::init_env(env.lib_env);
3844

39-
let db =
40-
Database::from_db_url(env.db_env.db_url.db_url, env.db_env.redis_url.redis_url).await?;
45+
let db = Database::from_db_url(
46+
env.db_env.db_url.db_url.get(),
47+
env.db_env.redis_url.redis_url.get(),
48+
)
49+
.await?;
4150

4251
let cmd = Command::parse();
4352

crates/compute-player-map-ranking/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
anyhow = { workspace = true }
8-
clap = { version = "4.5.48", features = ["derive"] }
8+
clap = { version = "4.5.54", features = ["derive"] }
99
dotenvy = { workspace = true }
1010
mkenv = { workspace = true }
1111
player-map-ranking = { path = "../player-map-ranking" }

crates/compute-player-map-ranking/src/main.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ use std::{
1111
use anyhow::Context as _;
1212
use chrono::{DateTime, Days, Months, Utc};
1313
use clap::Parser as _;
14-
use mkenv::Env as _;
14+
use mkenv::prelude::*;
1515
use records_lib::{DbUrlEnv, time::Time};
1616
use sea_orm::Database;
1717

18-
mkenv::make_env! {AppEnv includes [DbUrlEnv as db_env]:}
18+
mkenv::make_config! {
19+
struct AppEnv {
20+
db_env: { DbUrlEnv },
21+
}
22+
}
1923

2024
#[derive(Clone)]
2125
struct SinceDuration {
@@ -96,10 +100,11 @@ async fn main() -> anyhow::Result<()> {
96100
})
97101
.context("couldn't write header to map ranking file")?;
98102

99-
let db_url = AppEnv::try_get()
100-
.context("couldn't initialize environment")?
101-
.db_env
102-
.db_url;
103+
let app_config = AppEnv::define();
104+
app_config
105+
.try_init()
106+
.map_err(|e| anyhow::anyhow!("couldn't initialize environment: {e}"))?;
107+
let db_url = app_config.db_env.db_url.get();
103108
let db = Database::connect(db_url)
104109
.await
105110
.context("couldn't connect to database")?;

crates/entity/src/entities/maps.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use sea_orm::entity::prelude::*;
22

33
/// A ShootMania Obstacle map in the database.
4-
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
4+
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
55
#[sea_orm(table_name = "maps")]
66
pub struct Model {
77
/// The map ID.
@@ -32,6 +32,8 @@ pub struct Model {
3232
pub gold_time: Option<i32>,
3333
/// The author time of the map.
3434
pub author_time: Option<i32>,
35+
/// The score of the player, calculated periodically.
36+
pub score: f64,
3537
}
3638

3739
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

crates/entity/src/entities/players.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use sea_orm::entity::prelude::*;
22

33
/// A player in the database.
4-
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
4+
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
55
#[sea_orm(table_name = "players")]
66
pub struct Model {
77
/// The player ID.
@@ -20,6 +20,8 @@ pub struct Model {
2020
pub admins_note: Option<String>,
2121
/// The player role.
2222
pub role: u8,
23+
/// The score of the player, calculated periodically.
24+
pub score: f64,
2325
}
2426

2527
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

crates/game_api/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tracing = { workspace = true }
1919
tracing-subscriber = { workspace = true, features = ["env-filter"] }
2020
actix-web = { workspace = true }
2121
actix-cors = { workspace = true }
22-
actix-http = "3.11.0"
22+
actix-http = "3.11.2"
2323
async-graphql-actix-web = { workspace = true }
2424
tracing-actix-web = { workspace = true }
2525
reqwest = { workspace = true, features = ["multipart"] }
@@ -44,12 +44,12 @@ graphql-api = { path = "../graphql-api" }
4444
serde_json = { workspace = true }
4545

4646
[dev-dependencies]
47-
records-lib = { path = "../records_lib" }
47+
test-env = { path = "../test-env" }
48+
records-lib = { path = "../records_lib", features = ["tracing", "mock"] }
4849

4950
[features]
5051
default = ["request_filter"]
5152
request_filter = ["dep:pin-project-lite", "dep:request_filter"]
5253
auth = []
53-
mysql = ["records-lib/mysql"]
54-
postgres = ["records-lib/postgres"]
55-
test = ["records-lib/test"]
54+
mysql = ["records-lib/mysql", "test-env/mysql"]
55+
postgres = ["records-lib/postgres", "test-env/postgres"]

0 commit comments

Comments
 (0)