Skip to content

Commit

Permalink
Merge pull request #3162 from uw-it-aca/qa
Browse files Browse the repository at this point in the history
Resolve MUWM-5364 (#3161)
  • Loading branch information
fanglinfang authored Sep 27, 2024
2 parents 76ceffd + 4491413 commit 4216f7c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
12 changes: 6 additions & 6 deletions myuw/test/util/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"sws", "/student/v5/section", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"sws", "/student/v5/section", status=503), 60 * 15)
"sws", "/student/v5/section", status=503), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3"), HALF_HOUR)
self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"gws", "/group_sws/v3", status=500), 60 * 15)
"gws", "/group_sws/v3", status=500), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person"), ONE_HOUR)
self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"pws", "/identity/v2/person", status=503), 60 * 15)
"pws", "/identity/v2/person", status=503), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid"), FOUR_HOURS)
Expand All @@ -77,7 +77,7 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid", status=409), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"uwnetid", "/nws/v1/uwnetid", status=500), 60 * 15)
"uwnetid", "/nws/v1/uwnetid", status=500), 60 * 7)

self.assertEqual(cache.get_cache_expiration_time(
"grad", "/services/students"), FOUR_HOURS)
Expand All @@ -99,12 +99,12 @@ def test_get_cache_time(self):
self.assertEqual(cache.get_cache_expiration_time(
"mailman", "/uw_list_manager/api/v1/list/", status=404), 60 * 7)
self.assertEqual(cache.get_cache_expiration_time(
"mailman", "/uw_list_manager/api/v1/list/", status=500), 60 * 15)
"mailman", "/uw_list_manager/api/v1/list/", status=500), 60 * 7)

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)
"uwidp", "/idp/profile/oidc/keyset", status=500), 60 * 7)


class TestMyUWCache(TestCase):
Expand Down
2 changes: 0 additions & 2 deletions myuw/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def get_cache_expiration_time(self, service, url, status=None):
return FIVE_SECONDS

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

if "sws" == service:
Expand Down
5 changes: 3 additions & 2 deletions myuw/views/rest_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def get_proxy_url(self, request, service, url):
elif service == "canvas":
regid = get_regid(get_input_value(request.POST, "uwregid"))
url = (
f"api/v1/users/sis_user_id:{regid}/enrollments?" +
f"state[]=active&type[]=StudentEnrollment")
f"api/v1/users/sis_user_id:{regid}/enrollments?state[]=active"
+ f"&type[]=StudentEnrollment&page=first&per_page=500"
)
elif service == "grad":
params = self.format_params(request)
params['id'] = get_student_system_key(params['id'])
Expand Down
16 changes: 13 additions & 3 deletions myuw_vue/components/home/summaries.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</span>
</a>
</div>
<div v-if="isHfsReady || isLibraryReady" class="col-md-10">
<div v-if="loadData && (isHfsReady || isLibraryReady)" class="col-md-10">
<div class="row float-md-end" style="padding: 0 10px;">
<a
v-if="hfs && hfs.student_husky_card"
Expand Down Expand Up @@ -162,6 +162,11 @@ export default {
computed: {
...mapState({
termData: (state) => state.termData,
alum: (state) => state.user.affiliations.alumni,
student: (state) => state.user.affiliations.student,
employee: (state) => state.user.affiliations.all_employee,
past_stud: (state) => state.user.affiliations.past_stud,
past_emp: (state) => state.user.affiliations.past_employee,
}),
...mapState('hfs', {
hfs: (state) => state.value,
Expand All @@ -177,10 +182,15 @@ export default {
isLibraryReady: 'isReady',
isLibraryErrored: 'isErrored',
}),
loadData() {
return (this.alum || this.student || this.past_stud || this.employee || this.past_emp);
},
},
mounted() {
this.fetchHfs();
this.fetchLibrary();
if (this.loadData) {
this.fetchHfs();
this.fetchLibrary();
}
},
methods: {
...mapActions('hfs', {
Expand Down
12 changes: 11 additions & 1 deletion myuw_vue/tests/summaries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ describe('Summaries', () => {
hfs,
library,
},
state: {},
state: {
user: {
affiliations: {
alumni: false,
student: false,
past_stud: false,
all_employee: false,
past_employee: false,
}
}
},
});
});

Expand Down

0 comments on commit 4216f7c

Please sign in to comment.