Preserve entry positions in cache, bump when adding new ones#167
Preserve entry positions in cache, bump when adding new ones#167
Conversation
PR Review: Preserve entry positions in cacheAfter reviewing the changes, I found one issue that should be addressed: 🟡 Code QualityPosition mutation of cached objects The bump logic directly mutates the foreach (var e in entries)
{
if (e.id != entry.id && e.position >= entry.position)
{
e.position += 1; // Mutates cached object
}
}If external code holds references to these entries (via Suggested fix: Document this behavior in the method XML comments, or consider if entries should be immutable with a new instance created when positions change. Given the caching architecture, documentation is likely sufficient: /// <summary>
/// Note: When bumpPositions=true, this method mutates the position field of existing cached entries.
/// </summary>
public void UpsertEntry(string internalName, LeaderboardEntry entry, bool bumpPositions = false)All other aspects look good - the implementation correctly handles the insert/update distinction, tests cover the new behavior thoroughly, and the change aligns with the PR's stated goal. |
d69bb0f to
132a47c
Compare
132a47c to
e104d96
Compare
No description provided.