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 4aa1ec0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/NexusMods.App/TelemetryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.DependencyInjection;
using NexusMods.Abstractions.Library.Models;
using NexusMods.Abstractions.Loadouts;
using NexusMods.Abstractions.MnemonicDB.Attributes;
using NexusMods.Abstractions.NexusWebApi;
using NexusMods.Abstractions.Telemetry;
using NexusMods.App.BuildInfo;
Expand Down Expand Up @@ -66,13 +65,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 4aa1ec0

Please sign in to comment.