mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-04 02:34:13 +02:00
uploads/profiles
This commit is contained in:
parent
7bbaa70481
commit
d82fb05d68
16 changed files with 276 additions and 24 deletions
|
|
@ -370,16 +370,16 @@ impl GameMode {
|
|||
#[derive(Default, Debug, Deserialize)]
|
||||
pub struct Filter {
|
||||
#[serde(default)]
|
||||
mode: GameMode,
|
||||
pub mode: GameMode,
|
||||
#[serde(default)]
|
||||
map: String,
|
||||
pub map: String,
|
||||
#[serde(default)]
|
||||
#[serde(deserialize_with = "deserialize_array")]
|
||||
players: Vec<SteamId>,
|
||||
pub players: Vec<SteamId>,
|
||||
#[serde(default)]
|
||||
before: Option<i32>,
|
||||
pub before: Option<i32>,
|
||||
#[serde(default)]
|
||||
uploader: Option<i32>,
|
||||
pub uploader: Option<SteamId>,
|
||||
}
|
||||
|
||||
fn deserialize_array<'de, D, T>(deserializer: D) -> Result<Vec<T>, D::Error>
|
||||
|
|
@ -420,7 +420,12 @@ impl Filter {
|
|||
query.and_where(Expr::col(Demos::Id).lt(*before));
|
||||
}
|
||||
if let Some(uploader) = &self.uploader {
|
||||
query.and_where(Expr::col(Demos::Uploader).eq(*uploader));
|
||||
query
|
||||
.inner_join(
|
||||
Users::Table,
|
||||
Expr::col((Users::Table, Users::Id)).equals((Demos::Table, Demos::Uploader)),
|
||||
)
|
||||
.and_where(Expr::col(Users::SteamId).eq(uploader));
|
||||
}
|
||||
if !self.players.is_empty() && self.players.len() < 19 {
|
||||
let mut player = self.players.iter();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use std::str::FromStr;
|
|||
use steamid_ng::SteamID;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(untagged)]
|
||||
pub enum SteamId {
|
||||
Id(u64),
|
||||
Raw(Cow<'static, str>),
|
||||
|
|
@ -161,3 +162,9 @@ impl From<SteamId> for Value {
|
|||
Value::String(Some(Box::new(value.steamid64())))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&SteamId> for Value {
|
||||
fn from(value: &SteamId) -> Self {
|
||||
Value::String(Some(Box::new(value.steamid64())))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::data::steam_id::SteamId;
|
||||
use crate::Result;
|
||||
use crate::{Error, Result};
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::Rng;
|
||||
use reqwest::get;
|
||||
|
|
@ -60,6 +60,9 @@ impl User {
|
|||
}
|
||||
|
||||
async fn fetch(steam_id: &SteamId) -> Result<Profile> {
|
||||
let SteamId::Id(steam_id) = steam_id else {
|
||||
return Err(Error::NotFound);
|
||||
};
|
||||
let response = get(format!(
|
||||
"https://steamcommunity.com/profiles/{steam_id}?xml=1"
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue