Skip to content

Commit

Permalink
Merge branch 'qa' into f/hx-toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang authored Sep 24, 2024
2 parents a63b9c1 + 062a2fb commit b3a6563
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
5 changes: 5 additions & 0 deletions myuw/test/util/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"mailman", "/uw_list_manager/api/v1/list/", status=500), 60 * 15)

self.assertEqual(cache.get_cache_expiration_time(
"uwidp", "/idp/profile/oidc/keyset", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"uwidp", "/idp/profile/oidc/keyset", status=500), 60 * 15)


class TestMyUWCache(TestCase):

Expand Down
26 changes: 5 additions & 21 deletions myuw/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def get_cache_expiration_time(self, service, url, status=None):
if "myplan" == service:
return FIVE_SECONDS

if "sws" == service:
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS

if "sws" == service:
if re.match(r'^/student/v5/term/', url):
return ONE_DAY

Expand All @@ -52,31 +52,15 @@ def get_cache_expiration_time(self, service, url, status=None):
return ONE_DAY

if "gws" == service:
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS
return HALF_HOUR

if "pws" == service:
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS
return ONE_HOUR

if "uwnetid" == service:
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS
return FOUR_HOURS

if "mailman" == service:
if status and status != 200:
if status >= 500:
return FIFTEEN_MINS
return SEVEN_MINS
return ONE_DAY

return FOUR_HOURS
Expand Down

0 comments on commit b3a6563

Please sign in to comment.