Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mod counting #2318

Merged
merged 1 commit into from
Dec 2, 2024
Merged
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
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
Loading