Implement applicant pool functionality in school simulation, allowing for the management of job seekers who are not yet part of the school roster. Update the catalog to include staffing definitions and enhance the API to support applicant data retrieval. Revise the school architecture to handle applicant refresh logic and ensure proper integration with existing roster management. Update tests to validate the new applicant functionalities and ensure robustness in handling staffing scenarios.
This commit is contained in:
@@ -41,20 +41,8 @@ public static class RosterGenerator
|
||||
people.AddRange(members);
|
||||
}
|
||||
|
||||
var nextFamily = plans.Count;
|
||||
var adults = people.Count(person => !person.IsStudent);
|
||||
while (adults < demand.Staff.Count)
|
||||
{
|
||||
var (family, member) = FamilyFactory.CreateStaffOnly(catalog, names, schoolSeed, nextFamily, when);
|
||||
families.Add(family);
|
||||
people.Add(member);
|
||||
nextFamily++;
|
||||
adults++;
|
||||
}
|
||||
|
||||
var staffed = AssignStaff(people, demand.Staff);
|
||||
var classes = FillClasses(demand.Classes, staffed);
|
||||
return new Roster(staffed, families, classes);
|
||||
var classes = FillClasses(demand.Classes, people);
|
||||
return new Roster(people, families, classes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,48 +64,6 @@ public static class RosterGenerator
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<Person> AssignStaff(List<Person> people, IReadOnlyList<StaffOpening> openings)
|
||||
{
|
||||
if (openings.Count == 0)
|
||||
{
|
||||
return people;
|
||||
}
|
||||
|
||||
var jobs = new Dictionary<string, StaffOpening>(StringComparer.Ordinal);
|
||||
var index = 0;
|
||||
foreach (var person in people)
|
||||
{
|
||||
if (person.IsStudent || index >= openings.Count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
jobs[person.Id] = openings[index];
|
||||
index++;
|
||||
}
|
||||
|
||||
if (jobs.Count == 0)
|
||||
{
|
||||
return people;
|
||||
}
|
||||
|
||||
var result = new Person[people.Count];
|
||||
for (var i = 0; i < people.Count; i++)
|
||||
{
|
||||
var person = people[i];
|
||||
result[i] = jobs.TryGetValue(person.Id, out var job)
|
||||
? person with
|
||||
{
|
||||
IsStaff = true,
|
||||
Position = job.Position,
|
||||
WorkplaceRoomId = job.RoomId,
|
||||
}
|
||||
: person;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static IReadOnlyList<SchoolClass> FillClasses(
|
||||
IReadOnlyList<SchoolClass> classes,
|
||||
IReadOnlyList<Person> people)
|
||||
|
||||
Reference in New Issue
Block a user