Merge pull request #2354 from coreos-inc/license-sorting

Change entitlement sorting to sort *valid* entitlements by reverse expiration time
This commit is contained in:
josephschorr 2017-02-15 16:24:51 -05:00 committed by GitHub
commit 8f01cb959a
2 changed files with 106 additions and 2 deletions

View file

@ -187,6 +187,14 @@ class EntitlementValidationResult(object):
return self.get_status() == EntitlementStatus.met
def __lt__(self, rhs):
# If this result has the same status as another, return the result with an expiration date
# further in the future, as it will be more relevant. The results may expire, but so long as
# this result is valid, so will the entitlement.
if self.get_status() == rhs.get_status():
return (self.entitlement.expiration.expiration_date >
rhs.entitlement.expiration.expiration_date)
# Otherwise, sort lexically by status.
return self.get_status() < rhs.get_status()
def __repr__(self):