mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 09:18:27 -04:00
add: Added club rank in .clubinfo
This commit is contained in:
@@ -123,6 +123,8 @@ public partial class Xp
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var rank = _service.GetClubRank(club.Id);
|
||||
|
||||
await Response()
|
||||
.Paginated()
|
||||
.Items(allUsers)
|
||||
@@ -135,6 +137,7 @@ public partial class Xp
|
||||
.WithDescription(GetText(strs.level_x(lvl.Level + $" ({club.Xp} xp)")))
|
||||
.AddField(GetText(strs.desc),
|
||||
string.IsNullOrWhiteSpace(club.Description) ? "-" : club.Description)
|
||||
.AddField(GetText(strs.rank), $"#{rank}", true)
|
||||
.AddField(GetText(strs.owner), club.Owner.ToString(), true)
|
||||
// .AddField(GetText(strs.level_req), club.MinimumLevelReq.ToString(), true)
|
||||
.AddField(GetText(strs.members),
|
||||
|
@@ -134,6 +134,18 @@ public class ClubService : INService, IClubService
|
||||
return club is not null;
|
||||
}
|
||||
|
||||
public async Task<int> GetClubRank(int clubId)
|
||||
{
|
||||
await using var uow = _db.GetDbContext();
|
||||
|
||||
var rank = await uow.Clubs
|
||||
.ToLinqToDBTable()
|
||||
.Where(x => x.Xp > (uow.Clubs.First(c => c.Id == clubId).Xp))
|
||||
.CountAsyncLinqToDB();
|
||||
|
||||
return rank + 1;
|
||||
}
|
||||
|
||||
public ClubApplyResult ApplyToClub(IUser user, ClubInfo club)
|
||||
{
|
||||
using var uow = _db.GetDbContext();
|
||||
|
@@ -23,6 +23,7 @@ public interface IClubService
|
||||
ClubKickResult Kick(ulong kickerId, string userName, out ClubInfo club);
|
||||
List<ClubInfo> GetClubLeaderboardPage(int page);
|
||||
Task<ClubRenameResult> RenameClubAsync(ulong userId, string clubName);
|
||||
Task<int> GetClubRank(int clubId);
|
||||
}
|
||||
|
||||
public enum ClubApplyResult
|
||||
|
@@ -889,6 +889,7 @@
|
||||
"club_kick_hierarchy": "Only club owner can kick club admins. Owner can't be kicked.",
|
||||
"club_renamed": "Club has been renamed to {0}",
|
||||
"club_name_taken": "A club with that name already exists.",
|
||||
"rank": "Rank",
|
||||
"template_reloaded": "Xp template has been reloaded.",
|
||||
"expr_edited": "Expression Edited",
|
||||
"self_assign_are_exclusive": "You can only choose 1 role from each group.",
|
||||
|
Reference in New Issue
Block a user