in libmozevent/phabricator.py [0:0]
def is_expired_build(self, build):
"""
Check if a build has expired, using its Phabricator diff information
Returns True when the build has expired and should not be processed
"""
assert isinstance(build, PhabricatorBuild)
# We need Phabricator diff details to get the date
if build.diff is None:
try:
diffs = self.api.search_diffs(diff_id=build.diff_id)
if not diffs:
raise Exception(f"Diff {build.diff_id} not found on Phabricator")
build.diff = diffs[0]
except Exception as e:
logger.warn("Failed to load diff", build=str(build), err=str(e))
return False
# Then we can check on the expiry date
date_created = build.diff.get("dateCreated")
if not date_created:
logger.warn("No creation date found", build=str(build))
return False
logger.info("Found diff creation date", build=str(build), created=date_created)
return datetime.now() - datetime.fromtimestamp(date_created) > self.build_expiry