osu: Implement map length on server ranks

This commit is contained in:
Natsu Kagami 2024-03-06 00:01:38 +01:00
parent a50f44ad90
commit 11f32ccf04
Signed by: nki
GPG key ID: 55A032EB38B49ADB
12 changed files with 229 additions and 71 deletions

View file

@ -1,12 +0,0 @@
{
"db_name": "SQLite",
"query": "INSERT\n INTO osu_users(user_id, username, id, last_update, pp_std, pp_taiko, pp_mania, pp_catch, failures)\n VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT (user_id) WHERE id = ? DO UPDATE\n SET\n last_update = excluded.last_update,\n username = excluded.username,\n pp_std = excluded.pp_std,\n pp_taiko = excluded.pp_taiko,\n pp_mania = excluded.pp_mania,\n pp_catch = excluded.pp_catch,\n failures = excluded.failures\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 10
},
"nullable": []
},
"hash": "26a910506c0613936be169df13320dfd7f9d3df62a35ba63c61efc5de70e750d"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\"\n FROM osu_users",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\",\n std_weighted_map_length\n FROM osu_users",
"describe": {
"columns": [
{
@ -47,6 +47,11 @@
"name": "failures: u8",
"ordinal": 8,
"type_info": "Int64"
},
{
"name": "std_weighted_map_length",
"ordinal": 9,
"type_info": "Float"
}
],
"parameters": {
@ -61,8 +66,9 @@
true,
true,
true,
false
false,
true
]
},
"hash": "5753fe315c9a55154d2d80e6d293dc8abffcf426b845624a42cd0bfefc75fb74"
"hash": "6ef67ca385287a4cef9fdd47bf4258ec9de4802d90dbb2ab48de32c1a4ada601"
}

View file

@ -0,0 +1,12 @@
{
"db_name": "SQLite",
"query": "INSERT\n INTO osu_users(user_id, username, id, last_update, pp_std, pp_taiko, pp_mania, pp_catch, failures, std_weighted_map_length)\n VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT (user_id) WHERE id = ? DO UPDATE\n SET\n last_update = excluded.last_update,\n username = excluded.username,\n pp_std = excluded.pp_std,\n pp_taiko = excluded.pp_taiko,\n pp_mania = excluded.pp_mania,\n pp_catch = excluded.pp_catch,\n failures = excluded.failures,\n std_weighted_map_length = excluded.std_weighted_map_length\n ",
"describe": {
"columns": [],
"parameters": {
"Right": 11
},
"nullable": []
},
"hash": "a06efa1b12c2c7c9cf5b83bff796c0e59d61596cb609c4bb952edc2d64cec868"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\"\n FROM osu_users WHERE id = ?",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\",\n std_weighted_map_length\n FROM osu_users WHERE id = ?",
"describe": {
"columns": [
{
@ -47,6 +47,11 @@
"name": "failures: u8",
"ordinal": 8,
"type_info": "Int64"
},
{
"name": "std_weighted_map_length",
"ordinal": 9,
"type_info": "Float"
}
],
"parameters": {
@ -61,8 +66,9 @@
true,
true,
true,
false
false,
true
]
},
"hash": "08f2568a69a14ae240a24264238d4abc7aea5eee67d6062d049f0d37031e4d7a"
"hash": "b098282e73cc6fd435330f6ecd446b1a1cd2aeb89517b7ee09e7e6f8d6e0cd79"
}

View file

@ -1,6 +1,6 @@
{
"db_name": "SQLite",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\"\n FROM osu_users WHERE user_id = ?",
"query": "SELECT\n user_id as \"user_id: i64\",\n username,\n id as \"id: i64\",\n last_update as \"last_update: DateTime\",\n pp_std, pp_taiko, pp_mania, pp_catch,\n failures as \"failures: u8\",\n std_weighted_map_length\n FROM osu_users WHERE user_id = ?",
"describe": {
"columns": [
{
@ -47,6 +47,11 @@
"name": "failures: u8",
"ordinal": 8,
"type_info": "Int64"
},
{
"name": "std_weighted_map_length",
"ordinal": 9,
"type_info": "Float"
}
],
"parameters": {
@ -61,8 +66,9 @@
true,
true,
true,
false
false,
true
]
},
"hash": "700ec95294d9a4f21e3d7ff53f15f5dc739bffe8fedc19e35cbb576b6dd2e948"
"hash": "df0aa5065268e59c68990ab46ab4a90ec3137398e83b3d0c626209306804399a"
}

View file

@ -0,0 +1,5 @@
-- Add migration script here
ALTER TABLE osu_users
ADD COLUMN std_weighted_map_length DOUBLE NULL DEFAULT NULL;

View file

@ -14,6 +14,8 @@ pub struct OsuUser {
pub pp_catch: Option<f64>,
/// Number of consecutive update failures
pub failures: u8,
pub std_weighted_map_length: Option<f64>,
}
impl OsuUser {
@ -30,7 +32,8 @@ impl OsuUser {
id as "id: i64",
last_update as "last_update: DateTime",
pp_std, pp_taiko, pp_mania, pp_catch,
failures as "failures: u8"
failures as "failures: u8",
std_weighted_map_length
FROM osu_users WHERE user_id = ?"#,
user_id
)
@ -52,7 +55,8 @@ impl OsuUser {
id as "id: i64",
last_update as "last_update: DateTime",
pp_std, pp_taiko, pp_mania, pp_catch,
failures as "failures: u8"
failures as "failures: u8",
std_weighted_map_length
FROM osu_users WHERE id = ?"#,
osu_id
)
@ -74,7 +78,8 @@ impl OsuUser {
id as "id: i64",
last_update as "last_update: DateTime",
pp_std, pp_taiko, pp_mania, pp_catch,
failures as "failures: u8"
failures as "failures: u8",
std_weighted_map_length
FROM osu_users"#,
)
.fetch_many(conn)
@ -90,8 +95,8 @@ impl OsuUser {
{
query!(
r#"INSERT
INTO osu_users(user_id, username, id, last_update, pp_std, pp_taiko, pp_mania, pp_catch, failures)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)
INTO osu_users(user_id, username, id, last_update, pp_std, pp_taiko, pp_mania, pp_catch, failures, std_weighted_map_length)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
ON CONFLICT (user_id) WHERE id = ? DO UPDATE
SET
last_update = excluded.last_update,
@ -100,7 +105,8 @@ impl OsuUser {
pp_taiko = excluded.pp_taiko,
pp_mania = excluded.pp_mania,
pp_catch = excluded.pp_catch,
failures = excluded.failures
failures = excluded.failures,
std_weighted_map_length = excluded.std_weighted_map_length
"#,
self.user_id,
self.username,
@ -111,7 +117,10 @@ impl OsuUser {
self.pp_mania,
self.pp_catch,
self.failures,
self.user_id).execute(conn).await?;
self.std_weighted_map_length,
self.user_id,
).execute(conn).await?;
Ok(())
}