+ @staticmethod
+ def until(t=None):
+ """ Returns time suitable for use as upper time boundary for check.
+
+ Defaults to 'five minutes ago' to avoid issues with time between
+ change stamp set and model save.
+ Cuts the microsecond part to avoid issues with DBs where time has
+ more precision.
+
+ """
+ # set to five minutes ago, to avoid concurrency issues
+ if t is None:
+ t = datetime.now() - timedelta(seconds=settings.API_WAIT)
+ # set to whole second in case DB supports something smaller
+ return t.replace(microsecond=0)
+