Skip to content

Commit

Permalink
chore: add timed cache
Browse files Browse the repository at this point in the history
  • Loading branch information
AfaqShuaib09 committed Feb 17, 2025
1 parent 6874160 commit 5cd9966
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions edxval/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
The internal API for VAL.
"""


import logging
from enum import Enum
from uuid import uuid4
Expand All @@ -18,6 +16,7 @@
from lxml.etree import Element, SubElement
from pysrt.srtexc import Error

import cachetools.func
from edxval.config.waffle import OVERRIDE_EXISTING_IMPORTED_TRANSCRIPTS
from edxval.exceptions import (
InvalidTranscriptFormat,
Expand Down Expand Up @@ -733,6 +732,7 @@ def get_videos_for_course(course_id, sort_field=None, sort_dir=SortDirection.asc
)


@cachetools.func.ttl_cache(maxsize=None, ttl=24 * 60 * 60)
def get_transcript_languages(course_id, provider_type):
"""
Returns a list of languages for which transcripts are available for a course
Expand All @@ -749,7 +749,7 @@ def get_transcript_languages(course_id, provider_type):
video__edx_video_id__in=CourseVideo.objects.filter(
course_id=course_id
).values_list("video__edx_video_id", flat=True)
).select_related("video")
).select_related("video",)
for transcript in video_transcripts:
if transcript.provider == provider_type:
transcript_languages.add(transcript.language_code)
Expand Down
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pillow # for reserved keywords linter
edx-toggles>=2.0.0
lxml
pysrt
cachetools
2 changes: 2 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# make upgrade
#
cachetools==5.5.1
# via tox
annotated-types==0.7.0
# via pydantic
anyio==4.8.0
Expand Down

0 comments on commit 5cd9966

Please sign in to comment.