ImpectAPI / impectPy

Access data from the Impect customer API
MIT License
15 stars 0 forks source link

XML generation fails for matches that go into penalty shootout #39

Closed Flosch1006 closed 2 hours ago

Flosch1006 commented 4 hours ago

When a match goes into penalty shootout, the XML generation fails because of the following code section:

    # define function to calculate start time
    def start_time(gameTimeInSec, periodId):
        # get period offset
        offset = offsets[f"p{periodId}"]
        # calculate and return start time
        return max(gameTimeInSec - (periodId - 1) * 10000 + offset - lead, 0)

    # define function to calculate end time
    def end_time(gameTimeInSec, periodId, duration):
        # get period offset
        offset = offsets[f"p{periodId}"]
        # calculate and return end time
        return gameTimeInSec - (periodId - 1) * 10000 + offset + duration + lag

    # apply start and end time functions
    events["start"] = events.apply(
        lambda x: start_time(x["gameTimeInSec"], x["periodId"]), axis=1)
    events["end"] = events.apply(
        lambda x: end_time(x["gameTimeInSec"], x["periodId"], x["duration"]), axis=1)

Penalty shootouts have the period_id = 5 but there is no timestamp input for the function for p = 5. A new input has to be added to account for penalty shootouts.

Flosch1006 commented 2 hours ago

merged into release branch