Ejemplo n.º 1
0
def update(requests, experts, scheduleTime):
    """
    Runs the matching function for each client request.
    Requires: requests (ClientsCollection), the collection of clients
    Requires: experts (ExpertsCollection), the collection of experts
    Ensures: tuple of (schedule, updatedExperts)
             schedule (Schedule) is the collection of matches for
              the schedule file.
             updatedExperts (ExpertsCollection) is the updated list of
              experts.
    """

    newExperts = ExpertsCollection(experts.getExpertsList())
    scheduleOutput = Schedule()

    # Running each of the clients in the requests collection parameter
    # through the matchClient function. Updating the Experts each time,
    # generating a Schedule collection and an updated Experts collection.

    for client in requests.items():
        matchResults = matchClient(client, newExperts, scheduleTime)
        scheduleOutput.addToSchedule(matchResults[0])
        newExperts = matchResults[1]

    return scheduleOutput, newExperts