Skip to content

Commit 3e1f157

Browse files
authored
Merge pull request #430 from uw-it-aca/qa
Qa
2 parents 54c48ff + 3ae0c12 commit 3e1f157

23 files changed

+477
-37
lines changed

myuw/dao/affiliation.py

+68-19
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ def get_all_affiliations(request):
4646
if hasattr(request, 'myuw_user_affiliations'):
4747
return request.myuw_user_affiliations
4848

49-
enrolled_campuses = get_current_quarter_course_campuses(request)
5049
is_fyp = False
5150
try:
5251
is_fyp = is_thrive_viewer()
@@ -62,9 +61,9 @@ def get_all_affiliations(request):
6261
"employee": is_employee(),
6362
"fyp": is_fyp,
6463
"faculty": is_faculty(),
65-
"seattle": enrolled_campuses["seattle"] or is_seattle_student(),
66-
"bothell": enrolled_campuses["bothell"] or is_bothell_student(),
67-
"tacoma": enrolled_campuses["tacoma"] or is_tacoma_student(),
64+
"seattle": is_seattle_student(),
65+
"bothell": is_bothell_student(),
66+
"tacoma": is_tacoma_student(),
6867
}
6968
# add 'official' campus info
7069
official_campuses = _get_official_campuses(get_main_campus(request))
@@ -122,21 +121,6 @@ def _get_official_campuses(campuses):
122121
return official_campuses
123122

124123

125-
def get_current_quarter_course_campuses(request):
126-
"""
127-
Returns a dictionary indicating the campuses that the student
128-
has enrolled in the current quarter.
129-
"""
130-
try:
131-
current_quarter_sche = get_current_quarter_schedule(request)
132-
except Exception as ex:
133-
log_exception(logger,
134-
'get_current_quarter_course_campuses',
135-
traceback.format_exc())
136-
current_quarter_sche = None
137-
return _get_campuses_by_schedule(current_quarter_sche)
138-
139-
140124
def get_base_campus(request):
141125
"""
142126
Return one currently enrolled campus.
@@ -163,3 +147,68 @@ def get_base_campus(request):
163147
campus = ""
164148
pass
165149
return campus
150+
151+
152+
def _build_cache_method(name, method):
153+
name = "myuw_cache_%s" % name
154+
155+
def generated(request):
156+
if hasattr(request, name):
157+
return getattr(request, name)
158+
value = method()
159+
setattr(request, name, value)
160+
return value
161+
return generated
162+
163+
164+
request_cached_is_grad_student = _build_cache_method("grad_student",
165+
is_grad_student)
166+
167+
168+
request_cached_is_undergrad = _build_cache_method("undergrad",
169+
is_undergrad_student)
170+
171+
172+
request_cached_is_student = _build_cache_method("student",
173+
is_student)
174+
175+
176+
request_cached_is_pce_student = _build_cache_method("pce_student",
177+
is_pce_student)
178+
179+
request_cached_is_student_employee = _build_cache_method("student_employee",
180+
is_student_employee)
181+
182+
183+
request_cached_is_employee = _build_cache_method("student_employee",
184+
is_employee)
185+
186+
187+
request_cached_is_faculty = _build_cache_method("faculty",
188+
is_faculty)
189+
190+
191+
def wrapped_is_seattle(request):
192+
return is_seattle_student()
193+
194+
195+
def wrapped_is_tacoma(request):
196+
return is_tacoma_student()
197+
198+
199+
def wrapped_is_bothell(request):
200+
return is_bothell_student()
201+
202+
203+
def affiliation_prefetch():
204+
return [request_cached_is_grad_student,
205+
request_cached_is_undergrad,
206+
request_cached_is_student,
207+
request_cached_is_pce_student,
208+
request_cached_is_student_employee,
209+
request_cached_is_employee,
210+
request_cached_is_faculty,
211+
wrapped_is_seattle,
212+
wrapped_is_tacoma,
213+
wrapped_is_bothell,
214+
]

myuw/dao/card_display_dates.py

+3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ def get_reg_data(now, request):
175175
"""
176176
now is the second after mid-night
177177
"""
178+
if hasattr(request, "myuw_reg_data"):
179+
return request.myuw_reg_data
178180
term_reg_data = {
179181
"after_start": False,
180182
"after_summer1_start": False,
@@ -190,6 +192,7 @@ def get_reg_data(now, request):
190192
# We also need to be able to show the term after next, in spring quarter
191193
term_after_next = get_term_after(next_term)
192194
get_term_reg_data(now, term_after_next, term_reg_data)
195+
request.myuw_reg_data = term_reg_data
193196
return term_reg_data
194197

195198

myuw/dao/enrollment.py

+7
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,10 @@ def get_main_campus(request):
3737
for major in enrollment.majors:
3838
campuses.append(major.campus)
3939
return campuses
40+
41+
42+
def enrollment_prefetch():
43+
def _method(request):
44+
return get_current_quarter_enrollment(request)
45+
46+
return [_method]

myuw/dao/library.py

+12
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,15 @@ def get_subject_guide_by_section(section):
6464

6565
log_time(logger, logid, timer)
6666
return subject_guide.guide_url
67+
68+
69+
def library_resource_prefetch():
70+
def build_method(campus):
71+
def _method(request):
72+
get_default_subject_guide(campus)
73+
return _method
74+
75+
methods = []
76+
for campus in ['seattle', 'tacoma', 'bothell']:
77+
methods.append(build_method(campus))
78+
return methods

myuw/dao/pws.py

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ def is_student():
5252
"""
5353
res = _get_person_of_current_user()
5454
return res.is_student
55+
56+
57+
def person_prefetch():
58+
def _method(request):
59+
return _get_person_of_current_user()
60+
return [_method]

myuw/dao/schedule.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import logging
66
from restclients.models.sws import ClassSchedule
77
from restclients.sws.registration import get_schedule_by_regid_and_term
8+
from restclients.thread import generic_prefetch
9+
from restclients.library.currics import get_subject_guide_for_section_params
810
from myuw.logger.timer import Timer
911
from myuw.logger.logback import log_resp_time, log_exception
1012
from myuw.dao.pws import get_regid_of_current_user
@@ -30,13 +32,30 @@ def _get_schedule(regid, term):
3032
str(regid) + ',' + str(term.year) + ',' + term.quarter)
3133
timer = Timer()
3234
try:
33-
return get_schedule_by_regid_and_term(regid, term, False)
35+
return get_schedule_by_regid_and_term(regid, term, False,
36+
myuw_section_prefetch)
3437
finally:
3538
log_resp_time(logger,
3639
logid,
3740
timer)
3841

3942

43+
def myuw_section_prefetch(data):
44+
primary = data["PrimarySection"]
45+
params = [primary["Year"],
46+
primary["Quarter"],
47+
primary["CurriculumAbbreviation"],
48+
primary["CourseNumber"],
49+
data["SectionID"]
50+
]
51+
52+
key = "library-%s-%s-%s-%s-%s" % (tuple(params))
53+
method = generic_prefetch(get_subject_guide_for_section_params,
54+
params)
55+
56+
return [[key, method]]
57+
58+
4059
def get_schedule_by_term(request, term):
4160
"""
4261
Return the actively enrolled sections for the current user

myuw/dao/term.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ def get_previous_quarter(request):
138138
"""
139139
for the current quarter refered in the user session.
140140
"""
141-
return get_term_before(get_current_quarter(request))
141+
if hasattr(request, "myuw_previous_quarter"):
142+
return request.myuw_previous_quarter
143+
term = get_term_before(get_current_quarter(request))
144+
request.myuw_previous_quarter = term
145+
return term
142146

143147

144148
def is_past(term, request):
@@ -318,3 +322,35 @@ def get_eod_specific_quarter_last_instruction(year, quarter):
318322
Only the summer full term is relevant.
319323
"""
320324
return get_specific_term(year, quarter).get_eod_last_instruction()
325+
326+
327+
# The affilliation method caches values on the request object, but this one
328+
# is just designed to get values into our caching system.
329+
def _get_term_method(year, quarter):
330+
def generated(request):
331+
get_specific_term(year, quarter)
332+
return generated
333+
334+
335+
def current_terms_prefetch(request):
336+
# This triggers a call to get_current_term when using the file dao.
337+
# That request won't happen on test/production
338+
compare = get_comparison_date(request)
339+
year = compare.year
340+
month = compare.year
341+
342+
methods = []
343+
344+
for quarter in ('autumn', 'summer', 'spring', 'winter'):
345+
methods.append(_get_term_method(year, quarter))
346+
347+
if month < 4:
348+
methods.append(_get_term_method(year-1, 'autumn'))
349+
350+
if month > 6:
351+
methods.append(_get_term_method(year+1, 'winter'))
352+
353+
if month > 9:
354+
methods.append(_get_term_method(year+1, 'spring'))
355+
356+
return methods

myuw/dao/uwemail.py

+7
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,10 @@ def _get_email_forwarding_by_uwnetid(uwnetid):
2424

2525
def get_email_forwarding_for_current_user():
2626
return _get_email_forwarding_by_uwnetid(get_netid_of_current_user())
27+
28+
29+
def index_forwarding_prefetch():
30+
def _method(request):
31+
get_email_forwarding_for_current_user()
32+
33+
return [_method]

myuw/data/thrive_content.csv

+23-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,26 @@ http://depts.washington.edu/hhpccweb/health-resource/the-importance-of-getting-a
1414
",,,,
1515
9,11.21.16,autumn,,,,,,,,,,,,,,
1616
10,11.28.16,autumn,60,Week 10,Life & Wellness,"Money, Money, Money",Dining dollars dwindling? Coffee consuming cash? Now’s the time to get a handle on your finances.,Track your spending for a week. Then create a realistic budget (see tips below). ,U101: Budgeting in College,https://vimeo.com/129501760/c3cc750393,6 Money Tips for Students,http://money.usnews.com/money/blogs/my-money/2013/10/03/6-must-follow-money-tips-for-college-students,,,,
17-
11,12.5.16,autumn,67,Week 11,Life & Wellness,You’re Almost There!,Finish the quarter strong by making healthy habits a priority. Research has shown that better sleep = better exam grades. Take care of yourself and your brain will thank you.,"Aim for 7-8 hours of sleep a night. Balance individual studying with group work. Take 10 minutes to recharge every hour. Snack smart for brain power. And when you’re done, celebrate! ",Sleep Linked to Higher Test Scores,http://www.huffingtonpost.com/2014/06/22/sleep-hours-exam-performance_n_5516643.html,Study Tips for Tests,http://depts.washington.edu/aspuw/develop/helpful-tips/preparing-for-tests/,,,,
17+
11,12.5.16,autumn,67,Week 11,Life & Wellness,You’re Almost There!,Finish the quarter strong by making healthy habits a priority. Research has shown that better sleep = better exam grades. Take care of yourself and your brain will thank you.,"Aim for 7-8 hours of sleep a night. Balance individual studying with group work. Take 10 minutes to recharge every hour. Snack smart for brain power. And when you’re done, celebrate! ",Sleep Linked to Higher Test Scores,http://www.huffingtonpost.com/2014/06/22/sleep-hours-exam-performance_n_5516643.html,Study Tips for Tests,http://depts.washington.edu/aspuw/develop/helpful-tips/preparing-for-tests/,,,,
18+
1,1.1.17,winter,-2,Week 1,Planning & Goals,Welcome back!,What are your hopes and aspirations for 2017? What did you learn in your first quarter at UW that you can build on?,Set aside time for yourself -- or ask a friend to join you -- to take a look at the link below and choose two resolutions that speak to you. ,New Year’s Resolutions for College Students,http://collegelife.about.com/od/cocurricularlife/a/10-Sample-New-Years-Resolutions-For-College-Students.htm,,,,,,,,
19+
2,1.8.17,winter,5,Week 2,Learning Network,Commit to Community,Develop your skills while making a difference in your community. Your passion and commitment are needed.,Volunteer on MLK Day of Service. Learn more and reflect on your leadership skills at a fireside talk. ,UW MLK Day Events,http://www.washington.edu/carlson/events/mlk-day-of-service/,Husky Leadership Firesides,http://huskyleadership.uw.edu/programs/leadership-firesides/,Leadership & Service Learning Opportunities,http://www.washington.edu/carlson,,,,
20+
3,1.15.17,winter,12,Week 3,Planning & Goals,Scholarships 101,"Scholarships may still be available for this year, and many others offer funding next year for school and related activities.",Search the scholarship database based on your interests and activities. Use the filters to find scholarships that apply to you.,Scholarship Database,http://expd.uw.edu/expo/scholarships,Study Abroad Scholarships,http://goglobal.uw.edu,Research & Leadership Scholarships,http://expd.uw.edu/mge,Scholarship Advising,http://expd.uw.edu/scholarships,,
21+
4,1.22.17,winter,19,Week 4,Planning & Goals,Considering Study Abroad? ,"Many students who study abroad say it changed their lives, and sometimes their course of study. Interested? Browse the student study abroad stories below!","Talk to upperclass people about their study abroad experiences to learn what might be in it for you. Or if you're ready to start planning, check out the Getting Started resource or start looking for a program.",Browse Student Stories,http://www.washington.edu/studyabroad/student-stories/hana-peoples/,Getting Started with Study Abroad,http://www.washington.edu/studyabroad/students/getting-started/,Find a Study Abroad Program,http://www.washington.edu/studyabroad/students/find-a-program/,Upcoming Study Abroad Opportunities,http://www.washington.edu/studyabroad/now-accepting-applications-for/,,
22+
5,1.29.17,winter,26,Week 5,Exploring Directions,Internships and Exploration,"Want to explore an interest, gain practical experience, and add to your resume? Find an internship – or craft your own!","Learn about internships, and reflect on what you want out of the experience. Use this knowledge to guide you as you explore.",How to Find an Internship,https://careers.uw.edu/internships/,Why Visit the Career and Internship Center Now?,https://careers.uw.edu/wp-content/uploads/sites/25/2016/08/First-year-student-2016-2017-all-infographics-FINAL-WEB-2.pdf,,,,,,
23+
6,2.5.17,winter,33,Week 6,Exploring Directions,"Revisiting Plans, Exploring Options",Thinking about courses for next quarter? Now is a great time to revisit plans you had when you arrived at UW. Have your interests changed? Are you drawn to something new?,"Browse department websites, talk with an adviser, and take courses that interest you. These steps can help you explore majors and potential back-ups. Use MyPlan to track your course options.",Choosing Courses at the UW, http://www.washington.edu/uaa/advising/academic-planning/choosing-courses/,UAA Advising,https://www.washington.edu/uaa/advising/,Departmental Advising Directory,http://www.washington.edu/uaa/advising/finding-help/advising-offices-by-program/,U101: How to Choose a Major,https://vimeo.com/129504066/a816a7a7de,MyPlan,https://myplan.washington.edu/student/myplan/course
24+
7,2.12.17,winter,40,Week 7,Life & Wellness,Battle the Winter Blues,"With dark skies, cold weather, and increased time indoors, winter can impact both mental and physical health. Reach out if you're sad, rest if you're sick. Take steps to boost your winter wellness.","Take owernship for your health and healthy habits -- take the Healthy Huskies pledge! Prevent illness and improve your mood by exercising regularly, eating healthy, getting plenty of sleep, and keeping hydrated. ",Healthy Huskies Pledge,http://washington.edu/healthyhuskies/,Light Therapy for Seasonal Affective Disorder,https://www.washington.edu/counseling/services/light-therapy-for-sad/,24-hour UW Consulting Nurse - (206) 221-2517, http://depts.washington.edu/hhpccweb/consulting-nurse-service/,Hall Health Services for Students, http://depts.washington.edu/hhpccweb/especially-for-uw-seattle-students-and-their-families/,,
25+
8,2.19.17,winter,,,,,,,,,,,,,,,,
26+
9,2.26.17,winter,,,,,,,,,,,,,,,,
27+
10,3.5.17,winter,61,Week 10,Study Skills,Finals: Pace Your Prep,"Say no to cramming and say yes to cardio! Prep smart for finals by planning your study strategy: solo review, time with study partners, and time for self-care.",Check out the tips below and make a study plan. Strategizing now can help you retain what you've learned and decrease stress.,Proven Tips for Finals Preparation,http://blog.suny.edu/2013/12/scientifically-the-best-ways-to-prepare-for-final-exams/,IMA Hours,https://www.washington.edu/ima/facilities/hours/,Find Study Space with Scout, https://scout.uw.edu/,,,,
28+
,,,,,,,,,,,,,,,,,,
29+
1,3.26.17,spring,-1,Week 1,Life & Wellness,Fail Forward,"Viewed in the right light, challenges--even failure--can help you develop an attitude of healthy resilience. ","Learn the difference between a ""fixed"" vs. ""growth"" mindset. How can you apply these concepts to your own life? Learn about the UW Relience Lab efforts on campus.",Fixed vs. Growth Mindset,https://www.brainpickings.org/2014/01/29/carol-dweck-mindset/,Video on Mindset and Success,https://www.youtube.com/watch?v=pN34FNbOKXc&feature=youtu.be,UW Resilience Lab,http://webster.uaa.washington.edu/resilience/,,,,
30+
2,4.2.17,spring,6,Week 2,Planning & Goals,Experience is Golden,Internships and summer jobs can help you gain experience for your resume and money for your bank account. ,"For inspiration, check out 50 of the most interesting summer internships. See what Career & Internships Center events can help get you started. ",Awesome Summer Internships,http://www.fastweb.com/career-planning/articles/the-30-exciting-summer-jobs-for-college-students-grad-students,Career & Internship Center Events,https://careers.uw.edu/events/student/?stag%5B%5D=student,Husky Jobs,https://careers.uw.edu/jobs/,,,,
31+
3,4.9.17,spring,13,Week 3,Learning Network,People Power: Connections Count,Engaging with people who influence and challenge your thinking is critical to expanding the breadth and depth of your Husky Experience.,Choose intriguing classes. Make connections with instructors and peers--ask about their research and ideas. Google your profs as a start!,Choosing a Good Prof,http://www.fastweb.com/student-life/articles/how-to-pick-the-best-professors,Distinguished Teaching Award recipients,http://www.washington.edu/teaching/awards/awards-recipients/,Suggested Courses,http://www.washington.edu/uaa/advising/academic-planning/choosing-courses/courses-recommended-by-advisers/,,,,
32+
4,4.16.17,spring,20,Week 4,Study Skills,Writing & Research Rescue,Anxious about an upcoming paper or project? Get expert advice at any stage.,"Chat with a librarian (real-time help 24/7). Make an appointment at a campus writing center, or browse great online resources.",Ask a Librarian,http://www.lib.washington.edu/about/contact,Writing & Research Help,http://guides.lib.uw.edu/c.php?g=342041&p=2300216,Writing Advice A-Z,http://writingcenter.unc.edu/handouts/,,,,
33+
5,4.23.17,spring,27,Week 5,Life & Wellness,De-stress with Mindfulness,"Practicing mindfulness can boost immunity, increase attention span, and decrease stress.",Mindful breathing can help calm nerves. Close your eyes; take ten slow deep breaths. Inhale through your nose; exhale through your mouth. Focus carefully on each breath.,Video: Meditation 101,https://www.youtube.com/watch?v=rqoxYKtEWEc,Video: UW students talk about mental health and resources,https://www.youtube.com/watch?v=5e6QOb_FmGk&feature=player_embedded,Try Headspace Mindfulness App,https://www.headspace.com/,,,,
34+
6,4.30.17,spring,34,Week 6,Planning & Goals,Make the Most of Your Summer,There are lots of ways to gain experience over the next few months. Having fun trying new things!,"Consider getting involved with research, mentoring youth, or taking a unique summer job. The resources below can get you started, but also talk to advisers, friends and family. What's the best summer they ever had? ",Research and Mentoring Opportunities,http://expd.uw.edu/,Public Service Opportunities,http://www.washington.edu/carlson/service-opportunities/,UW Research Opportunities,http://www.washington.edu/undergradresearch/students/find/,Career & Internship Center,https://careers.uw.edu/,,
35+
7,5.7.17,spring,,,,,,,,,,,,,,,,
36+
8,5.14.17,spring,,,,,,,,,,,,,,,,
37+
9,5.21.17,spring,55,Week 9,Study Skills,"Finals Prep Refresher
38+
","Say no to cramming and say yes to cardio! Prep smart for finals by planning your study strategy: solo review, time with study partners, and time for self-care.",Check out the tips below and make a study plan. Strategizing now can help you retain what you've learned and decrease stress.,Proven Tips for Finals Preparation,http://blog.suny.edu/2013/12/scientifically-the-best-ways-to-prepare-for-final-exams/,IMA Hours,https://www.washington.edu/ima/facilities/hours/,Find Study Space with Scout,https://scout.uw.edu/,,,,
39+
10,5.28.17,spring,62,Week 10,Life & Wellness,Celebrate your Growth,You made it!! Take a moment to appreciate all the ways you've grown--in classes and beyond--during your first year at UW.,,,,,,,,,,,

0 commit comments

Comments
 (0)