Revert "query for jobevents based on table location"

This reverts commit 278dc521fffb85d4faa023ccd634044cfd3b3d75.
This commit is contained in:
Chris Meyers 2021-04-20 13:58:50 -04:00 committed by Jim Ladd
parent 6123b8e148
commit 34c4967d27

View File

@ -15,7 +15,7 @@ from django.utils.translation import ugettext_lazy as _
from psycopg2.errors import UntranslatableCharacter
from awx.conf.license import get_license
from awx.main.utils import get_awx_version, get_custom_venv_choices, camelcase_to_underscore, datetime_hook, get_event_partition_epoch
from awx.main.utils import get_awx_version, get_custom_venv_choices, camelcase_to_underscore, datetime_hook
from awx.main import models
from awx.main.analytics import register
@ -77,17 +77,7 @@ def events_slicing(key, since, until, last_gather):
lower = since or last_gather
if not since and last_entries.get(key):
lower = horizon
partition_epoch = get_event_partition_epoch()
# JobEvent.modified index was created at the partition epoch
# Events created before this are in a separate table that does not
# have this index.
if lower >= partition_epoch:
pk_values = models.JobEvent.objects.filter(modified__gte=lower, modified__lte=until).aggregate(Min('pk'), Max('pk'))
elif until < partition_epoch:
pk_values = models.JobEvent.objects.filter(created__gte=lower, created__lte=until).aggregate(Min('pk'), Max('pk'))
else:
pk_values = models.JobEvent.objects.filter(created__gte=lower, created__lte=partition_epoch).aggregate(Min('pk'))
pk_values.update(models.JobEvent.objects.filter(modified__gte=partition_epoch, modified__lte=until).aggregate(Max('pk')))
pk_values = models.JobEvent.objects.filter(modified__gte=lower, modified__lte=until).aggregate(Min('pk'), Max('pk'))
previous_pk = pk_values['pk__min'] - 1 if pk_values['pk__min'] is not None else 0
if not since and last_entries.get(key):