Skip to content

Commit

Permalink
feat: adding previous_usernames to UserSmall and all related endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
112batuhan committed Dec 6, 2024
1 parent 132cb71 commit 4873857
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/database/activity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ impl DatabaseClient {
user.groups,
user.ranked_and_approved_beatmapset_count
+ user.guest_beatmapset_count as user.ranked_maps,
user.previous_usernames,
fn::id_or_null(influence.out.id) as influence.id,
influence.out.username as influence.username,
influence.out.avatar_url as influence.avatar_url,
influence.out.country_code as influence.country_code,
influence.out.country_name as influence.country_name,
influence.out.groups as influence.groups,
influence.out.previous_usernames as influence.previous_usernames,
fn::add_possible_nulls(
influence.out.ranked_and_approved_beatmapset_count,
influence.out.guest_beatmapset_count
Expand Down
3 changes: 3 additions & 0 deletions src/database/influence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl DatabaseClient {
out.ranked_and_approved_beatmapset_count
+ out.guest_beatmapset_count as user.ranked_maps,
count(out<-influenced_by) as user.mentions,
out.previous_usernames as user.previous_usernames,
beatmaps,
description,
influence_type
Expand Down Expand Up @@ -204,6 +205,7 @@ impl DatabaseClient {
out.ranked_and_approved_beatmapset_count
+ out.guest_beatmapset_count as user.ranked_maps,
COUNT(->user<-influenced_by) as user.mentions,
out.previous_usernames as user.previous_usernames,
influence_type,
description,
beatmaps,
Expand Down Expand Up @@ -243,6 +245,7 @@ impl DatabaseClient {
in.ranked_and_approved_beatmapset_count
+ in.guest_beatmapset_count as user.ranked_maps,
COUNT(<-user<-influenced_by) as user.mentions,
in.previous_usernames as user.previous_usernames,
influence_type,
description
FROM $thing<-influenced_by
Expand Down
3 changes: 2 additions & 1 deletion src/database/leaderboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl DatabaseClient {
out.groups as user.groups,
out.ranked_and_approved_beatmapset_count
+ out.guest_beatmapset_count as user.ranked_maps,
count(out<-influenced_by) as user.mentions
count(out<-influenced_by) as user.mentions,
out.previous_usernames as user.previous_usernames
FROM
(SELECT
count() AS count,
Expand Down
5 changes: 4 additions & 1 deletion src/database/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct UserSmall {
/// This will have a number if the data is coming from database.
/// If the data comes from osu! API, then this will be null
pub mentions: Option<u32>,
pub previous_usernames: Vec<String>,
}

impl From<UserOsu> for UserSmall {
Expand All @@ -89,6 +90,7 @@ impl From<UserOsu> for UserSmall {
country_name: user.country.name,
ranked_maps: user.ranked_and_approved_beatmapset_count + user.guest_beatmapset_count,
mentions: None,
previous_usernames: user.previous_usernames,
}
}
}
Expand Down Expand Up @@ -339,7 +341,8 @@ impl DatabaseClient {
groups,
ranked_and_approved_beatmapset_count
+ guest_beatmapset_count as ranked_maps,
count(<-influenced_by) as mentions
count(<-influenced_by) as mentions,
previous_usernames
FROM $things;
",
)
Expand Down

0 comments on commit 4873857

Please sign in to comment.