mirror of
https://github.com/NoiTheCat/WorldTime.git
synced 2024-10-16 08:29:57 +00:00
Remove top 20 distinct zone limit
This commit is contained in:
parent
2a73283798
commit
689c14757a
2 changed files with 3 additions and 6 deletions
|
@ -29,9 +29,7 @@ public class CommandsBase : InteractionModuleBase<ShardedInteractionContext> {
|
|||
/// </summary>
|
||||
protected static string TzPrint(string zone, bool use12hr) {
|
||||
var tzdb = DateTimeZoneProviders.Tzdb;
|
||||
DateTimeZone tz = tzdb.GetZoneOrNull(zone)!;
|
||||
if (tz == null) throw new Exception("Encountered unknown time zone: " + zone);
|
||||
|
||||
DateTimeZone tz = tzdb.GetZoneOrNull(zone) ?? throw new Exception("Encountered unknown time zone: " + zone);
|
||||
var now = SystemClock.Instance.GetCurrentInstant().InZone(tz);
|
||||
var sortpfx = now.ToString("MMddHH", DateTimeFormatInfo.InvariantInfo);
|
||||
string fullstr;
|
||||
|
|
|
@ -73,11 +73,10 @@ public class UserCommands : CommandsBase {
|
|||
return;
|
||||
}
|
||||
|
||||
// Order times by popularity to limit how many are shown, group by printed name
|
||||
// Generate time and zone names to be displayed, group with associated user IDs
|
||||
var sortedlist = new SortedDictionary<string, List<ulong>>();
|
||||
var ampm = db.GuildSettings.Where(s => s.GuildId == Context.Guild.Id).SingleOrDefault()?.Use12HourTime ?? false;
|
||||
foreach ((string area, List<ulong> users) in userlist.OrderByDescending(o => o.Value.Count).Take(20)) {
|
||||
// Filter further to top 20 distinct timezones, even if they are not displayed in the final result
|
||||
foreach ((string area, List<ulong> users) in userlist.OrderByDescending(o => o.Value.Count)) {
|
||||
var areaprint = TzPrint(area, ampm);
|
||||
if (!sortedlist.ContainsKey(areaprint)) sortedlist.Add(areaprint, new List<ulong>());
|
||||
sortedlist[areaprint].AddRange(users);
|
||||
|
|
Loading…
Reference in a new issue