Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: Refactor AuthorHashes away from LinQ.
Browse files Browse the repository at this point in the history
  • Loading branch information
RiotNOR committed May 16, 2023
1 parent 606e07a commit 1bb2cd6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RotationSolver/Updaters/MajorUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void Enable()
}

static bool _work;
private static async void UpdateWork()
private static void UpdateWork()
{
if (!IsValid) return;
if (_work) return;
Expand Down
28 changes: 21 additions & 7 deletions RotationSolver/Updaters/RotationUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,26 @@ private static void LoadRotationsFromLocal(string relayFolder)
}
}

AuthorHashes = new SortedList<string, string>(
(from a in assemblies
select (a, a.GetCustomAttribute<AuthorHashAttribute>()) into author
where author.Item2 != null
group author by author.Item2 into gr
select (gr.Key.Hash, string.Join(", ", gr.Select(i => i.a.GetInfo().Author + " - " + i.a.GetInfo().Name))))
.ToDictionary(i => i.Hash, i => i.Item2));
AuthorHashes = new SortedList<string, string>();
foreach (var assembly in assemblies)
{
var authorHashAttribute = assembly.GetCustomAttribute<AuthorHashAttribute>();
if (authorHashAttribute != null)
{
var key = authorHashAttribute.Hash;
var value = $"{assembly.GetInfo().Author} - {assembly.GetInfo().Name}";

if (AuthorHashes.ContainsKey(key))
{
AuthorHashes[key] += $", {value}";
}
else
{
AuthorHashes.Add(key, value);
}
}
}


CustomRotations = (
from a in assemblies
Expand All @@ -105,6 +118,7 @@ select GetRotation(t) into rotation
group rotation by rotation.JobIDs[0] into rotationGrp
select new CustomRotationGroup(rotationGrp.Key, rotationGrp.First().JobIDs, CreateRotationSet(rotationGrp.ToArray()))).ToArray();


CustomRotationsDict = new SortedList<JobRole, CustomRotationGroup[]>
(CustomRotations.GroupBy(g => g.Rotations[0].Job.GetJobRole())
.ToDictionary(set => set.Key, set => set.OrderBy(i => i.JobId).ToArray()));
Expand Down

0 comments on commit 1bb2cd6

Please sign in to comment.