diff --git a/tracker/models/event.py b/tracker/models/event.py index ceb1b9ed0..a4d8afb21 100644 --- a/tracker/models/event.py +++ b/tracker/models/event.py @@ -21,6 +21,19 @@ from .fields import TimestampField from .util import LatestEvent +# TODO: remove when 3.10 is oldest supported version + +try: + from itertools import pairwise +except ImportError: + + def pairwise(iterable): + # pairwise('ABCDEFG') --> AB BC CD DE EF FG + a, b = itertools.tee(iterable) + next(b, None) + return zip(a, b) + + __all__ = [ 'Event', 'PostbackURL', @@ -547,7 +560,7 @@ def clean(self): 'order': 'Next anchor in the order would occur before this one' } ) - for c, n in itertools.pairwise( + for c, n in pairwise( itertools.chain( [self], SpeedRun.objects.filter(