feat: keep track of user submissions, refs #4
This commit is contained in:
@@ -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!");
|
||||
|
||||
Reference in New Issue
Block a user