Skip to content

Commit

Permalink
misc 修改版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
chr233 committed Jan 25, 2023
1 parent 3534567 commit d0a8c24
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
43 changes: 42 additions & 1 deletion XinjingdailyBot.Service/Data/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,12 @@ private async Task AutoLeaveChat(Chat? msgChat)
return (sb.ToString(), keyboard);
}

public async Task<string> GetUserBasicInfo(Users dbUser)
public string GetUserBasicInfo(Users dbUser)
{
var userNick = dbUser.FullName.EscapeHtml();
var level = _levelRepository.GetLevelName(dbUser.Level);
var group = _groupRepository.GetGroupName(dbUser.GroupID);
var status = dbUser.IsBan ? "封禁中" : "正常";

int totalPost = dbUser.PostCount - dbUser.ExpiredPostCount;
double passPercent = 1.0 * dbUser.AcceptCount / totalPost;
Expand All @@ -599,6 +600,7 @@ public async Task<string> GetUserBasicInfo(Users dbUser)
sb.AppendLine($"用户名: <code>{userNick}</code>");
sb.AppendLine($"用户ID: <code>{dbUser.UserID}</code>");
sb.AppendLine($"用户组: <code>{group}</code>");
sb.AppendLine($"状态: <code>{status}</code>");
sb.AppendLine($"等级: <code>{level}</code>");
sb.AppendLine($"投稿数量: <code>{totalPost}</code>");
sb.AppendLine($"投稿通过率: <code>{passPercent:0.00%}</code>");
Expand All @@ -608,5 +610,44 @@ public async Task<string> GetUserBasicInfo(Users dbUser)

return sb.ToString();
}

public async Task<string> GetUserRank(Users dbUser)
{
var now = DateTime.Now;
var prev30Days = now.AddDays(-30).AddHours(-now.Hour).AddMinutes(-now.Minute).AddSeconds(-now.Second);

StringBuilder sb = new();

if (dbUser.GroupID == 1)
{
if (dbUser.AcceptCount >= 1)
{
const int miniumPost = 10;

int acceptCountRank = await Queryable().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > dbUser.AcceptCount && x.ModifyAt >= prev30Days).CountAsync() + 1;

double ratio = 1.0 * dbUser.AcceptCount / dbUser.PostCount;
int acceptRatioRank = await Queryable().Where(x => !x.IsBan && !x.IsBot && x.GroupID == 1 && x.AcceptCount > miniumPost && x.ModifyAt >= prev30Days)
.Select(y => 100.0 * y.AcceptCount / y.PostCount).Where(x => x > ratio).CountAsync() + 1;

sb.AppendLine($"通过数排名: <code>{acceptCountRank}</code>");
sb.AppendLine($"通过率排名: <code>{acceptRatioRank}</code>");
}
else
{
sb.AppendLine("稿件数量太少, 未进入排行榜");
}
}
else
{
int activeUser = await Queryable().Where(x => !x.IsBan && !x.IsBot && x.ModifyAt >= prev30Days).CountAsync();
sb.AppendLine($"活跃用户数: <code>{activeUser}</code>");

sb.AppendLine($"管理员不参与用户排名");
sb.AppendLine($"可以使用命令 /userrank 查看总排名");
}

return sb.ToString();
}
}
}
2 changes: 1 addition & 1 deletion XinjingdailyBot.WebAPI/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;

[assembly: CLSCompliant(false)]
[assembly: AssemblyVersion("2.0.10.0")]
[assembly: AssemblyVersion("2.0.10.1")]

[assembly: AssemblyCopyright("Copyright @ 2023 Chr_")]
[assembly: AssemblyProduct("XinjingDaily Bot")]
Expand Down

0 comments on commit d0a8c24

Please sign in to comment.