From 4aa1ec00b78b813f0a5b52dfd55397bbbdaa7d5d Mon Sep 17 00:00:00 2001 From: erri120 Date: Wed, 27 Nov 2024 15:41:00 +0100 Subject: [PATCH] Fix mod counting --- src/NexusMods.App/TelemetryProvider.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/NexusMods.App/TelemetryProvider.cs b/src/NexusMods.App/TelemetryProvider.cs index 19fd7ecba0..6569d4034a 100644 --- a/src/NexusMods.App/TelemetryProvider.cs +++ b/src/NexusMods.App/TelemetryProvider.cs @@ -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; @@ -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(); }