From 68d2392399147b0bbc1dd9598a29abab9a448114 Mon Sep 17 00:00:00 2001 From: Tony Sappe <22781949+tony-sappe@users.noreply.github.com> Date: Wed, 10 Oct 2018 14:52:16 -0400 Subject: [PATCH] Re-adding API caching to data_dictionary API and fixing ordering issue --- usaspending_api/references/management/commands/load_rosetta.py | 2 +- usaspending_api/references/v2/views/data_dictionary.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/usaspending_api/references/management/commands/load_rosetta.py b/usaspending_api/references/management/commands/load_rosetta.py index c3ea8706cf..b20701bb55 100644 --- a/usaspending_api/references/management/commands/load_rosetta.py +++ b/usaspending_api/references/management/commands/load_rosetta.py @@ -84,7 +84,7 @@ def extract_data_from_source_file(path: str = None) -> dict: else: sections.append(section) - elements = {} + elements = OrderedDict() for i, row in enumerate(sheet.values): if i < 2: continue diff --git a/usaspending_api/references/v2/views/data_dictionary.py b/usaspending_api/references/v2/views/data_dictionary.py index e506226f61..a4e62d2869 100644 --- a/usaspending_api/references/v2/views/data_dictionary.py +++ b/usaspending_api/references/v2/views/data_dictionary.py @@ -2,6 +2,7 @@ from rest_framework.response import Response +from usaspending_api.common.cache_decorator import cache_response from usaspending_api.common.exceptions import NoDataFoundException from usaspending_api.common.views import APIDocumentationView from usaspending_api.references.models import Rosetta @@ -15,6 +16,7 @@ class DataDictionaryViewSet(APIDocumentationView): endpoint_doc: /references/data_dictionary.md """ + @cache_response() def get(self, request, format=None): try: api_response = Rosetta.objects.filter(document_name="api_response").values("document")[0]