Fix: Separate Splatoon specific Ranking Methods #65
6 changed files with 25 additions and 5 deletions
|
|
@ -31,6 +31,8 @@ jobs:
|
|||
- edition: super-mario-maker
|
||||
db_secret: DATABASE_SMM
|
||||
- edition: terraria
|
||||
|
||||
name: ${{ matrix.edition }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
|
|
|||
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -2618,6 +2618,7 @@ dependencies = [
|
|||
name = "rnex-rk"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rnex-rk-protos",
|
||||
"rnex-rmc",
|
||||
"rnex-server",
|
||||
|
|
|
|||
|
|
@ -59,11 +59,13 @@ pub struct CompetitionRankingScoreData {
|
|||
#[rmc_proto(112)]
|
||||
pub trait Ranking {
|
||||
#[method_id(16)]
|
||||
#[cfg(feature = "splatoon")]
|
||||
async fn competition_ranking_get_param(
|
||||
&self,
|
||||
param: CompetitionRankingGetParam,
|
||||
) -> Result<Vec<CompetitionRankingScoreInfo>, ErrorCode>;
|
||||
#[method_id(18)]
|
||||
#[cfg(feature = "splatoon")]
|
||||
async fn upload_competition_ranking_score(
|
||||
&self,
|
||||
param: UploadCompetitionData,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ datastore = ["database-support", "v3-8-15"]
|
|||
database-support = []
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.4"
|
||||
rnex-rmc = { path = "../../rnex-rmc" }
|
||||
rnex-util = { path = "../../rnex-util" }
|
||||
rnex-rk-protos = { path = "../../rnex-protocols/rk-protos" }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use rnex_rmc::response::ErrorCode;
|
||||
use rnex_server::{ConnectionInitData, EnvVarError, RnexManager, RnexModule, env_var};
|
||||
use std::str::FromStr;
|
||||
use cfg_if::cfg_if;
|
||||
use tracing::error;
|
||||
|
||||
use crate::user::RankingUser;
|
||||
|
|
@ -18,6 +19,7 @@ pub struct RankingModule;
|
|||
|
||||
impl RankingManager {
|
||||
// Seperate function because I cannot give a fuck right now
|
||||
#[cfg(feature = "splatoon")]
|
||||
async fn fetch_team_votes(&self, fest_id: u32) -> Result<Vec<u32>, ErrorCode> {
|
||||
let url_votes = format!("{}?splatfest_id={}", self.rnex_result_votes_get, fest_id);
|
||||
let Ok(response) = tokio::task::spawn_blocking(move || {
|
||||
|
|
@ -76,10 +78,20 @@ impl RnexModule for RankingModule {
|
|||
async fn create_manager(
|
||||
_: &rnex_server::ModuleHolder,
|
||||
) -> Result<Self::Manager, Self::InitError> {
|
||||
Ok(RankingManager {
|
||||
rnex_result_votes_get: env_var("RNEX_SPLATOON_RESULTS_VOTES_GET")?,
|
||||
rnex_result_post: env_var("RNEX_SPLATOON_RESULTS_POST")?,
|
||||
rnex_result_get: env_var("RNEX_SPLATOON_RESULTS_GET")?,
|
||||
})
|
||||
cfg_if!{
|
||||
if #[cfg(feature = "splatoon")] {
|
||||
Ok(RankingManager {
|
||||
rnex_result_votes_get: env_var("RNEX_SPLATOON_RESULTS_VOTES_GET")?,
|
||||
rnex_result_post: env_var("RNEX_SPLATOON_RESULTS_POST")?,
|
||||
rnex_result_get: env_var("RNEX_SPLATOON_RESULTS_GET")?,
|
||||
})
|
||||
} else {
|
||||
Ok(RankingManager {
|
||||
rnex_result_get: "".into(),
|
||||
rnex_result_post: "".into(),
|
||||
rnex_result_votes_get: "".into(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ pub struct CompetitionPostResults {
|
|||
}
|
||||
|
||||
impl Ranking for RankingUser {
|
||||
#[cfg(feature = "splatoon")]
|
||||
async fn competition_ranking_get_param(
|
||||
&self,
|
||||
param: CompetitionRankingGetParam,
|
||||
|
|
@ -93,6 +94,7 @@ impl Ranking for RankingUser {
|
|||
Ok(vec![info])
|
||||
}
|
||||
|
||||
#[cfg(feature = "splatoon")]
|
||||
async fn upload_competition_ranking_score(
|
||||
&self,
|
||||
param: UploadCompetitionData,
|
||||
|
|
|
|||
Loading…
Reference in a new issue