Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MixItUp.Base/Model/Currency/CurrencyModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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); } }

Expand Down
19 changes: 19 additions & 0 deletions MixItUp.Base/Util/SpecialIdentifierStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserService>().LoadAllUserData();

IEnumerable<UserV2Model> 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)
Expand Down