From ee09bca5586ea6d79098af92cb288d57c41ef01e Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Wed, 5 Apr 2017 16:50:38 -0400 Subject: [PATCH] change facts_recent to facts_latest --- awx/api/serializers.py | 2 +- awx/api/urls.py | 2 +- awx/api/views.py | 6 +++--- awx/main/access.py | 8 ++++---- awx/main/migrations/0037_v320_fact_recent.py | 14 +++++++------- awx/main/models/fact.py | 12 ++++++------ 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 51ac883ee8..d954f532af 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1157,7 +1157,7 @@ class HostSerializer(BaseSerializerWithVariables): ad_hoc_commands = self.reverse('api:host_ad_hoc_commands_list', kwargs={'pk': obj.pk}), ad_hoc_command_events = self.reverse('api:host_ad_hoc_command_events_list', kwargs={'pk': obj.pk}), fact_versions = self.reverse('api:host_fact_versions_list', kwargs={'pk': obj.pk}), - facts_recent = self.reverse('api:host_facts_recent_list', kwargs={'pk': obj.pk}), + facts_latest = self.reverse('api:host_facts_latest_list', kwargs={'pk': obj.pk}), )) if obj.inventory: res['inventory'] = self.reverse('api:inventory_detail', kwargs={'pk': obj.inventory.pk}) diff --git a/awx/api/urls.py b/awx/api/urls.py index 64a2749d01..973075a651 100644 --- a/awx/api/urls.py +++ b/awx/api/urls.py @@ -114,7 +114,7 @@ host_urls = patterns('awx.api.views', #url(r'^(?P[0-9]+)/single_fact/$', 'host_single_fact_view'), url(r'^(?P[0-9]+)/fact_versions/$', 'host_fact_versions_list'), url(r'^(?P[0-9]+)/fact_view/$', 'host_fact_compare_view'), - url(r'^(?P[0-9]+)/facts_recent/$', 'host_facts_recent_list'), + url(r'^(?P[0-9]+)/facts_latest/$', 'host_facts_latest_list'), ) group_urls = patterns('awx.api.views', diff --git a/awx/api/views.py b/awx/api/views.py index edb032874a..9f6f2d5b1a 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -1835,11 +1835,11 @@ class HostFactCompareView(SystemTrackingEnforcementMixin, SubDetailAPIView): return Response(self.serializer_class(instance=fact_entry).data) -class HostFactsRecentList(SubListAPIView): +class HostFactsLatestList(SubListAPIView): - model = FactRecent + model = FactLatest parent_model = Host - relationship = 'facts_recent' + relationship = 'facts_latest' serializer_class = FactSerializer new_in_320 = True diff --git a/awx/main/access.py b/awx/main/access.py index 151b00b20c..f4c4486faf 100644 --- a/awx/main/access.py +++ b/awx/main/access.py @@ -2264,12 +2264,12 @@ class RoleAccess(BaseAccess): return False -class FactRecentAccess(BaseAccess): +class FactLatestAccess(BaseAccess): - model = FactRecent + model = FactLatest def get_queryset(self): - return FactRecent.objects.distinct() + return FactLatest.objects.distinct() register_access(User, UserAccess) @@ -2304,4 +2304,4 @@ register_access(WorkflowJobTemplateNode, WorkflowJobTemplateNodeAccess) register_access(WorkflowJobNode, WorkflowJobNodeAccess) register_access(WorkflowJobTemplate, WorkflowJobTemplateAccess) register_access(WorkflowJob, WorkflowJobAccess) -register_access(FactRecent, FactRecentAccess) +register_access(FactLatest, FactLatestAccess) diff --git a/awx/main/migrations/0037_v320_fact_recent.py b/awx/main/migrations/0037_v320_fact_recent.py index 9a8ffb58b8..d7ca92f154 100644 --- a/awx/main/migrations/0037_v320_fact_recent.py +++ b/awx/main/migrations/0037_v320_fact_recent.py @@ -9,7 +9,7 @@ from psycopg2.extensions import AsIs # AWX import awx.main.fields -from awx.main.models import FactRecent +from awx.main.models import FactLatest class Migration(migrations.Migration): @@ -20,13 +20,13 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name='FactRecent', + name='FactLatest', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('timestamp', models.DateTimeField(default=None, help_text='Date and time of the corresponding fact scan gathering time.', editable=False)), ('module', models.CharField(max_length=128)), ('facts', awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True)), - ('host', models.ForeignKey(related_name='facts_recent', to='main.Host', help_text='Host for the facts that the fact scan captured.')), + ('host', models.ForeignKey(related_name='facts_latest', to='main.Host', help_text='Host for the facts that the fact scan captured.')), ], ), migrations.AlterField( @@ -35,10 +35,10 @@ class Migration(migrations.Migration): field=awx.main.fields.JSONBField(default={}, help_text='Arbitrary JSON structure of module facts captured at timestamp for a single host.', blank=True), ), migrations.AlterIndexTogether( - name='factrecent', + name='factlatest', index_together=set([('timestamp', 'module', 'host')]), ), - migrations.RunSQL([("CREATE INDEX fact_recent_facts_default_gin ON %s USING gin" - "(facts jsonb_path_ops);", [AsIs(FactRecent._meta.db_table)])], - [('DROP INDEX fact_recent_facts_default_gin;', None)]), + migrations.RunSQL([("CREATE INDEX fact_latest_facts_default_gin ON %s USING gin" + "(facts jsonb_path_ops);", [AsIs(FactLatest._meta.db_table)])], + [('DROP INDEX fact_latest_facts_default_gin;', None)]), ] diff --git a/awx/main/models/fact.py b/awx/main/models/fact.py index e07f37448a..3c4ffabc80 100644 --- a/awx/main/models/fact.py +++ b/awx/main/models/fact.py @@ -6,13 +6,13 @@ from django.utils.translation import ugettext_lazy as _ from awx.main.fields import JSONBField -__all__ = ('Fact', 'FactRecent') +__all__ = ('Fact', 'FactLatest') -class FactRecent(models.Model): +class FactLatest(models.Model): host = models.ForeignKey( 'Host', - related_name='facts_recent', + related_name='facts_latest', db_index=True, on_delete=models.CASCADE, help_text=_('Host for the facts that the fact scan captured.'), @@ -33,10 +33,10 @@ class FactRecent(models.Model): @staticmethod def add_fact(host_id, module, timestamp, facts): - qs = FactRecent.objects.filter(host_id=host_id, module=module) + qs = FactLatest.objects.filter(host_id=host_id, module=module) qs.delete() - fact_obj = FactRecent.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts) + fact_obj = FactLatest.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts) return fact_obj @@ -91,7 +91,7 @@ class Fact(models.Model): @staticmethod def add_fact(host_id, module, timestamp, facts): - FactRecent.add_fact(host_id=host_id, module=module, timestamp=timestamp, facts=facts) + FactLatest.add_fact(host_id=host_id, module=module, timestamp=timestamp, facts=facts) fact_obj = Fact.objects.create(host_id=host_id, module=module, timestamp=timestamp, facts=facts) fact_obj.save()