Skip to content

Commit

Permalink
Fix mod counting
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 27, 2024
1 parent fee4ee5 commit 69c16e8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/NexusMods.App/TelemetryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using NexusMods.App.UI;
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.ElementComparers;
using NexusMods.MnemonicDB.Abstractions.IndexSegments;
using NexusMods.MnemonicDB.Abstractions.Query;
using NexusMods.Paths;
using OneOf;
Expand Down Expand Up @@ -66,13 +68,16 @@ private int GetManagedGamesCount()

private Counters.LoadoutModCount[] GetModsPerLoadout()
{
return Loadout.All(_connection.Db)
.Where(x => x.IsVisible())
.Select(x =>
{
var count = x.Items.Count();
return new Counters.LoadoutModCount(x.Installation.Name, count);
})
var db = _connection.Db;
var dict = db
.Datoms(LibraryLinkedLoadoutItem.PrimaryAttribute)
.Select(datom => LoadoutItem.Load(db, datom.E))
.GroupBy(static item => item.LoadoutId)
.ToDictionary(static grouping => grouping.Key, static grouping => grouping.Count());

return Loadout.All(db)
.Where(static loadout => loadout.IsVisible())
.Select(loadout => new Counters.LoadoutModCount(loadout.Installation.Name, dict[loadout.LoadoutId]))
.ToArray();
}

Expand Down

0 comments on commit 69c16e8

Please sign in to comment.