Skip to content

Commit

Permalink
Merge branch 'master' into ui-requirements/70
Browse files Browse the repository at this point in the history
  • Loading branch information
sneha-sharma12 committed Apr 2, 2024
2 parents f95fe31 + 6586a1e commit 1fb44bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ckanext/ubdc/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

log = logging.getLogger(__name__)

from cachetools import cached
from cachetools import TTLCache

cache_time=tk.config.get('ckanext.stats.cache_time', 120)

@cached(cache=TTLCache(maxsize=1024, ttl=cache_time))
def popular_datasets(limit=3):
"""Return a list of the most popular datasets."""
packages = get_top_packages(limit)
Expand All @@ -20,13 +25,15 @@ def popular_datasets(limit=3):
return datasets


@cached(cache=TTLCache(maxsize=1024, ttl=cache_time))
def resources_count():
"""Return the total number of resources."""
context = {"model": model, "session": model.Session}
data_dict = {"query": "name:"}
return get_action("resource_search")(context, data_dict)["count"]


@cached(cache=TTLCache(maxsize=1024, ttl=cache_time))
def tags_count():
"""Return the total number of tags."""
context = {"model": model, "session": model.Session}
Expand Down Expand Up @@ -81,6 +88,7 @@ def get_field_to_question(value):
return get_field_to_question.get(value, value)


@cached(cache=TTLCache(maxsize=1024, ttl=86400))
def get_data_providers():
# Get the data provider only when they have the image to show on homepage
group_list = []
Expand Down

0 comments on commit 1fb44bb

Please sign in to comment.