mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-05-25 17:40:52 +00:00
Update rosu-v2
This commit is contained in:
parent
e0664760fb
commit
ea1c8d2cac
5 changed files with 9 additions and 10 deletions
|
@ -430,7 +430,7 @@ impl Beatmap {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct UserEvent(pub rosu_v2::model::recent_event::RecentEvent);
|
||||
pub struct UserEvent(pub rosu_v2::model::event::Event);
|
||||
|
||||
/// Represents a "achieved rank #x on beatmap" event.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
@ -445,7 +445,7 @@ impl UserEvent {
|
|||
/// Try to parse the event into a "rank" event.
|
||||
pub fn to_event_rank(&self) -> Option<UserEventRank> {
|
||||
match &self.0.event_type {
|
||||
rosu_v2::model::recent_event::EventType::Rank {
|
||||
rosu_v2::model::event::EventType::Rank {
|
||||
grade: _,
|
||||
rank,
|
||||
mode,
|
||||
|
|
|
@ -76,7 +76,7 @@ impl User {
|
|||
pub(crate) fn from_rosu(
|
||||
user: rosu::user::UserExtended,
|
||||
stats: rosu::user::UserStatistics,
|
||||
events: Vec<rosu::recent_event::RecentEvent>,
|
||||
events: Vec<rosu::event::Event>,
|
||||
) -> Self {
|
||||
Self {
|
||||
id: user.user_id as u64,
|
||||
|
@ -105,8 +105,8 @@ impl User {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<rosu::recent_event::RecentEvent> for UserEvent {
|
||||
fn from(value: rosu::recent_event::RecentEvent) -> Self {
|
||||
impl From<rosu::event::Event> for UserEvent {
|
||||
fn from(value: rosu::event::Event) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,9 +207,8 @@ pub mod builders {
|
|||
};
|
||||
let now = time::OffsetDateTime::now_utc()
|
||||
- time::Duration::DAY * self.event_days.unwrap_or(31);
|
||||
let mut events =
|
||||
handle_not_found(client.rosu.recent_events(user.user_id).limit(50).await)?
|
||||
.unwrap_or(vec![]);
|
||||
let mut events = handle_not_found(client.rosu.recent_activity(user.user_id).await)?
|
||||
.unwrap_or(vec![]);
|
||||
events.retain(|e| (now <= e.created_at));
|
||||
let stats = user.statistics.take().unwrap();
|
||||
Ok(Some(models::User::from_rosu(user, stats, events)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue