From f79025745b5e2922b178804611b1b87470cb1f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=85=B0=EF=B8=8F=F0=9F=85=B0=EF=B8=8F=F0=9F=85=B0?= =?UTF-8?q?=EF=B8=8F1=EF=B8=8F=E2=83=A36=EF=B8=8F=E2=83=A32=EF=B8=8F?= =?UTF-8?q?=E2=83=A3=20=E2=9C=94=EF=B8=8F?= Date: Tue, 6 Jan 2026 19:52:29 -0600 Subject: [PATCH] Add rank count special identifier for currencies $rankcount Will return the number of users who have the specific rank. --- MixItUp.Base/Model/Currency/CurrencyModel.cs | 3 +++ .../Util/SpecialIdentifierStringBuilder.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/MixItUp.Base/Model/Currency/CurrencyModel.cs b/MixItUp.Base/Model/Currency/CurrencyModel.cs index 11381440c..9712bd22a 100644 --- a/MixItUp.Base/Model/Currency/CurrencyModel.cs +++ b/MixItUp.Base/Model/Currency/CurrencyModel.cs @@ -198,6 +198,9 @@ public CurrencyModel() [JsonIgnore] public string AllTotalAmountDisplaySpecialIdentifier { get { return string.Format("{0}display", this.AllTotalAmountSpecialIdentifier); } } + [JsonIgnore] + public string RankCountSpecialIdentifierHeader { get { return string.Format("{0}rankcount", this.SpecialIdentifier); } } + [JsonIgnore] public string TopRegexSpecialIdentifier { get { return string.Format("{0}\\d+{1}", SpecialIdentifierStringBuilder.TopSpecialIdentifierHeader, this.SpecialIdentifier); } } diff --git a/MixItUp.Base/Util/SpecialIdentifierStringBuilder.cs b/MixItUp.Base/Util/SpecialIdentifierStringBuilder.cs index 1f1c29027..7204381da 100644 --- a/MixItUp.Base/Util/SpecialIdentifierStringBuilder.cs +++ b/MixItUp.Base/Util/SpecialIdentifierStringBuilder.cs @@ -403,6 +403,25 @@ await this.ReplaceNumberBasedRegexSpecialIdentifier(currency.TopRegexSpecialIden this.ReplaceSpecialIdentifier(currency.AllTotalAmountDisplaySpecialIdentifier, total.ToNumberDisplayString()); this.ReplaceSpecialIdentifier(currency.AllTotalAmountSpecialIdentifier, total.ToString()); } + + if (currency.IsRank && this.ContainsSpecialIdentifier(currency.RankCountSpecialIdentifierHeader)) + { + await ServiceManager.Get().LoadAllUserData(); + + IEnumerable applicableUsers = await SpecialIdentifierStringBuilder.GetAllNonExemptUsers(); + + foreach (RankModel rank in currency.Ranks.OrderByDescending(r => r.Name.Length)) + { + string rankSpecialIdentifier = SpecialIdentifierStringBuilder.ConvertToSpecialIdentifier(rank.Name); + string fullIdentifier = currency.RankCountSpecialIdentifierHeader + rankSpecialIdentifier; + + if (this.ContainsSpecialIdentifier(fullIdentifier)) + { + int count = applicableUsers.Count(u => currency.GetRank(u).Name.Equals(rank.Name, StringComparison.OrdinalIgnoreCase)); + this.ReplaceSpecialIdentifier(fullIdentifier, count.ToString()); + } + } + } } if (ChannelSession.Settings.QuotesEnabled && ChannelSession.Settings.Quotes.Count > 0)