From 4873857ed3af26707811f6c581afa4821acc0d42 Mon Sep 17 00:00:00 2001 From: 112batuhan Date: Fri, 6 Dec 2024 23:44:08 +0300 Subject: [PATCH] feat: adding previous_usernames to UserSmall and all related endpoints --- src/database/activity.rs | 2 ++ src/database/influence.rs | 3 +++ src/database/leaderboard.rs | 3 ++- src/database/user.rs | 5 ++++- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/database/activity.rs b/src/database/activity.rs index eb4df21..384a7a6 100644 --- a/src/database/activity.rs +++ b/src/database/activity.rs @@ -43,6 +43,7 @@ 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, @@ -50,6 +51,7 @@ impl DatabaseClient { 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 diff --git a/src/database/influence.rs b/src/database/influence.rs index 9908a77..b7c3390 100644 --- a/src/database/influence.rs +++ b/src/database/influence.rs @@ -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 @@ -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, @@ -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 diff --git a/src/database/leaderboard.rs b/src/database/leaderboard.rs index f8f94f3..2db82cc 100644 --- a/src/database/leaderboard.rs +++ b/src/database/leaderboard.rs @@ -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, diff --git a/src/database/user.rs b/src/database/user.rs index 64abcda..946bc41 100644 --- a/src/database/user.rs +++ b/src/database/user.rs @@ -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, + pub previous_usernames: Vec, } impl From for UserSmall { @@ -89,6 +90,7 @@ impl From 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, } } } @@ -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; ", )