feat: keep track of user submissions, refs #4

This commit is contained in:
2025-05-24 18:46:29 +02:00
parent fbb6d1a409
commit 5fdd6ec1d0
5 changed files with 278 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ userCheckTimer.OnOccurence += async (s, ea) =>
IsIntroduced = false,
LdapUserName = string.Empty,
AssociationInProgress = false,
WasChosenForSuggestionThisRound = false,
};
dci.Users?.Add(newUser);
needsSaving = true;
@@ -110,7 +111,16 @@ pickOfTheDayTimer.OnOccurence += async (s, ea) =>
await dci.DisposeAsync();
return;
}
var luckyUser = await dci.Users.ElementAtAsync((new Random()).Next(await dci.Users.CountAsync()));
var potentialUsers = dci.Users.Where(u => !u.WasChosenForSuggestionThisRound);
if (!potentialUsers.Any())
{
Console.WriteLine("Resetting suggestion count on users before resuming");
await dci.Users.ForEachAsync(u => u.WasChosenForSuggestionThisRound = false);
await dci.SaveChangesAsync();
potentialUsers = dci.Users.Where(u => !u.WasChosenForSuggestionThisRound);
}
Console.WriteLine("Today's pool of pickable users is: " + string.Join(", ", potentialUsers.Select(u => u.Name)));
var luckyUser = potentialUsers.ElementAt((new Random()).Next(potentialUsers.Count()));
if (luckyUser == null)
{
Console.WriteLine("Unable to determine today's lucky user!");