Skip to content

Commit

Permalink
Show exercises which fuzzy match in previous list
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamMorrow committed Oct 11, 2024
1 parent 2982e4a commit 7d19331
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions LiftLog.Lib/Util/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,27 @@ Func<T, ValueTask<V>> valueSelector

return immutableDictionaryBuilder.ToImmutable();
}

public static async ValueTask<ImmutableDictionary<K, V>> ToImmutableDictionaryAwaitAsync<
T,
K,
V
>(
this IAsyncEnumerable<T> source,
Func<T, ValueTask<K>> keySelector,
Func<T, ValueTask<V>> valueSelector,
IEqualityComparer<K> keyComparer
)
where K : notnull
{
var immutableDictionaryBuilder = ImmutableDictionary.CreateBuilder<K, V>(keyComparer);
await foreach (var item in source)
{
var key = keySelector(item);
var value = valueSelector(item);
immutableDictionaryBuilder.Add(await key, await value);
}

return immutableDictionaryBuilder.ToImmutable();
}
}
3 changes: 2 additions & 1 deletion LiftLog.Ui/Services/ProgressRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ public ValueTask<
)
.ToImmutableDictionaryAwaitAsync(
x => ValueTask.FromResult(x.Key),
async x => await x.Take(maxRecordsPerExercise).ToImmutableListValueAsync()
async x => await x.Take(maxRecordsPerExercise).ToImmutableListValueAsync(),
KeyedExerciseBlueprint.NormalizedNameOnlyEqualityComparer.Instance
);
}

Expand Down

0 comments on commit 7d19331

Please sign in to comment.