Skip to content

Commit

Permalink
Change cache timeout variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 9, 2024
1 parent 427620f commit e2932bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/donations/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get(self, request, *args, **kwargs):
# render a response
return render(request, self.template_name, context)

@cache_decorator(timeout=settings.CACHE_TIMEOUT_TINY, cache_key="ADMIN_STATS")
@cache_decorator(timeout=settings.TIMEOUT_CACHE_SHORT, cache_key="ADMIN_STATS")
def collect_stats(self):
return {
"timestamp": timezone.now(),
Expand Down
2 changes: 1 addition & 1 deletion backend/donations/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def validate_ngo_slug(cls, user, slug):

class NgosApi(TemplateView):
@staticmethod
@cache_decorator(timeout=settings.CACHE_TIMEOUT_SMALL, cache_key=ALL_NGOS_CACHE_KEY)
@cache_decorator(timeout=settings.TIMEOUT_CACHE_NORMAL, cache_key=ALL_NGOS_CACHE_KEY)
def _get_all_ngos() -> list:
return Ngo.active.order_by("name")

Expand Down
2 changes: 1 addition & 1 deletion backend/donations/views/my_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MyAccountView(BaseAccountView):
template_name = "ngo/my-account.html"

@staticmethod
@cache_decorator(timeout=settings.CACHE_TIMEOUT_TINY, cache_key_prefix="DONORS_BY_DONATION_YEAR")
@cache_decorator(timeout=settings.TIMEOUT_CACHE_SHORT, cache_key_prefix="DONORS_BY_DONATION_YEAR")
def _get_donors_by_donation_year(ngo: Ngo) -> OrderedDict[int, QuerySet[Donor]]:
if not ngo:
return OrderedDict()
Expand Down
6 changes: 3 additions & 3 deletions backend/donations/views/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class HomePage(TemplateView):
template_name = "index.html"

@staticmethod
@cache_decorator(timeout=settings.CACHE_TIMEOUT_MEDIUM, cache_key_prefix=ALL_NGO_IDS_CACHE_KEY)
@cache_decorator(timeout=settings.TIMEOUT_CACHE_LONG, cache_key_prefix=ALL_NGO_IDS_CACHE_KEY)
def _get_list_of_ngo_ids() -> list:
return list(Ngo.active.values_list("id", flat=True))

Expand Down Expand Up @@ -62,7 +62,7 @@ def get(self, request, *args, **kwargs):

return render(request, self.template_name, context)

@cache_decorator(timeout=settings.CACHE_TIMEOUT_TINY, cache_key_prefix=FRONTPAGE_NGOS_KEY)
@cache_decorator(timeout=settings.TIMEOUT_CACHE_SHORT, cache_key_prefix=FRONTPAGE_NGOS_KEY)
def _get_random_ngos(self, ngo_queryset: QuerySet, num_ngos: int):
all_ngo_ids = self._get_list_of_ngo_ids()
return ngo_queryset.filter(id__in=random.sample(all_ngo_ids, num_ngos))
Expand Down Expand Up @@ -91,7 +91,7 @@ class NgoListHandler(TemplateView):
template_name = "all-ngos.html"

@staticmethod
@cache_decorator(timeout=settings.CACHE_TIMEOUT_SMALL, cache_key=ALL_NGOS_CACHE_KEY)
@cache_decorator(timeout=settings.TIMEOUT_CACHE_NORMAL, cache_key=ALL_NGOS_CACHE_KEY)
def _get_all_ngos() -> list:
return Ngo.active.order_by("name")

Expand Down

0 comments on commit e2932bd

Please sign in to comment.