Using Exist's audit_period_ending in verifier instead of RawData's when

This commit is contained in:
Andrew Melton
2013-04-08 17:06:57 -04:00
parent 265512bcd6
commit 32bef7714e
2 changed files with 11 additions and 13 deletions

View File

@@ -427,7 +427,7 @@ class VerifierTestCase(unittest.TestCase):
models.InstanceExists.PENDING = 'pending' models.InstanceExists.PENDING = 'pending'
models.InstanceExists.VERIFYING = 'verifying' models.InstanceExists.VERIFYING = 'verifying'
filters = { filters = {
'raw__when__lte': dt.dt_to_decimal(when_max), 'audit_period_ending__lte': dt.dt_to_decimal(when_max),
'status': 'pending' 'status': 'pending'
} }
results.filter(**filters).AndReturn(results) results.filter(**filters).AndReturn(results)
@@ -456,7 +456,7 @@ class VerifierTestCase(unittest.TestCase):
models.InstanceExists.PENDING = 'pending' models.InstanceExists.PENDING = 'pending'
models.InstanceExists.VERIFYING = 'verifying' models.InstanceExists.VERIFYING = 'verifying'
filters = { filters = {
'raw__when__lte': dt.dt_to_decimal(when_max), 'audit_period_ending__lte': dt.dt_to_decimal(when_max),
'status': 'pending' 'status': 'pending'
} }
results.filter(**filters).AndReturn(results) results.filter(**filters).AndReturn(results)

View File

@@ -54,12 +54,10 @@ handler.setFormatter(formatter)
LOG.addHandler(handler) LOG.addHandler(handler)
def _list_exists(received_max=None, received_min=None, status=None): def _list_exists(ending_max=None, status=None):
params = {} params = {}
if received_max: if ending_max:
params['raw__when__lte'] = dt.dt_to_decimal(received_max) params['audit_period_ending__lte'] = dt.dt_to_decimal(ending_max)
if received_min:
params['raw__when__gt'] = dt.dt_to_decimal(received_min)
if status: if status:
params['status'] = status params['status'] = status
return models.InstanceExists.objects.select_related()\ return models.InstanceExists.objects.select_related()\
@@ -226,8 +224,8 @@ def _verify(exist):
results = [] results = []
def verify_for_range(pool, when_max, callback=None): def verify_for_range(pool, ending_max, callback=None):
exists = _list_exists(received_max=when_max, exists = _list_exists(ending_max=ending_max,
status=models.InstanceExists.PENDING) status=models.InstanceExists.PENDING)
count = exists.count() count = exists.count()
added = 0 added = 0
@@ -315,8 +313,8 @@ def _run(config, pool, callback=None):
with transaction.commit_on_success(): with transaction.commit_on_success():
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
kwargs = {settle_units: settle_time} kwargs = {settle_units: settle_time}
when_max = now - datetime.timedelta(**kwargs) ending_max = now - datetime.timedelta(**kwargs)
new = verify_for_range(pool, when_max, callback=callback) new = verify_for_range(pool, ending_max, callback=callback)
msg = "N: %s, P: %s, S: %s, E: %s" % ((new,) + clean_results()) msg = "N: %s, P: %s, S: %s, E: %s" % ((new,) + clean_results())
LOG.info(msg) LOG.info(msg)
@@ -352,8 +350,8 @@ def _run_once(config, pool, callback=None):
settle_time = config['settle_time'] settle_time = config['settle_time']
now = datetime.datetime.utcnow() now = datetime.datetime.utcnow()
kwargs = {settle_units: settle_time} kwargs = {settle_units: settle_time}
when_max = now - datetime.timedelta(**kwargs) ending_max = now - datetime.timedelta(**kwargs)
new = verify_for_range(pool, when_max, callback=callback) new = verify_for_range(pool, ending_max, callback=callback)
LOG.info("Verifying %s exist events" % new) LOG.info("Verifying %s exist events" % new)
while len(results) > 0: while len(results) > 0: