Skip to content

Commit

Permalink
Merge branch 'qa' into feature/MUWM-5233
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang authored Sep 24, 2024
2 parents d6a5093 + 062a2fb commit 340f7d2
Show file tree
Hide file tree
Showing 19 changed files with 289 additions and 122 deletions.
46 changes: 27 additions & 19 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

Expand All @@ -88,10 +88,10 @@ jobs:
exclude_paths: 'migrations'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-$(echo ${{ hashFiles('Dockerfile') }} | head -c 16)
Expand All @@ -107,7 +107,7 @@ jobs:
run: echo "VUE_DEVTOOLS=True" >> $GITHUB_ENV

- name: Build App Image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
target: app-container
tags: ${{ needs.context.outputs.image_tag }}
Expand All @@ -118,7 +118,7 @@ jobs:
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build Test Image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
with:
target: app-test-container
tags: app-test-container
Expand Down Expand Up @@ -147,10 +147,18 @@ jobs:
image_tag: ${{ needs.context.outputs.image_tag }}
gcp_json_key: ${{ secrets.GCP_JSON_KEY }}

- uses: actions/upload-artifact@v3
- name: Change ownership of coverage files
run: sudo chown runner:docker .coverage.*

- name: List all files in the workspace
run: ls -la

- name: Upload Python Coverage
uses: actions/upload-artifact@v4
with:
name: python-coverage
path: .coverage.*
include-hidden-files: true

outputs:
image_tag: ${{ steps.cicd.outputs.image_tag }}
Expand All @@ -163,9 +171,9 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand All @@ -187,9 +195,9 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -218,7 +226,7 @@ jobs:
apt install lcov -y
lcov -a lcov-jest.info -a coverage/lcov.info -o lcov.info
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: jest-cypress-coverage
path: lcov.info
Expand All @@ -229,25 +237,25 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: python-coverage

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: jest-cypress-coverage

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Set up Ruby 2.6
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
ruby-version: 3.3.5

- name: Record Test Results
env:
Expand All @@ -272,7 +280,7 @@ jobs:

steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Deployment Pipeline
if: >-
Expand Down
4 changes: 2 additions & 2 deletions docker/prod-values.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 120
minReplicas: 4
maxReplicas: 150
targetAverageUtilization: 100
resources:
limits:
Expand Down
73 changes: 46 additions & 27 deletions myuw/dao/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
from uw_canvas.sections import Sections
from uw_canvas.courses import Courses
from uw_canvas.models import CanvasCourse, CanvasSection
from uw_sws.exceptions import InvalidCanvasIndependentStudyCourse
from uw_sws.exceptions import (
InvalidCanvasIndependentStudyCourse, InvalidCanvasSection)
from myuw.dao import log_err
from myuw.dao.pws import get_regid_of_current_user
from myuw.dao.term import get_comparison_datetime

logger = logging.getLogger(__name__)
canvas_enrollments = Enrollments()


def canvas_prefetch():
Expand All @@ -26,9 +28,11 @@ def _method(request):
def get_canvas_active_enrollments(request):
if not hasattr(request, "canvas_act_enrollments"):
request.canvas_act_enrollments = (
Enrollments().get_enrollments_for_regid(
canvas_enrollments.get_enrollments_for_regid(
get_regid_of_current_user(request),
{'type': ['StudentEnrollment'], 'state': ['active']}))
logger.debug({'canvas_act_enrollments':
request.canvas_act_enrollments[0].json_data()})
return request.canvas_act_enrollments


Expand All @@ -37,34 +41,50 @@ def set_section_canvas_course_urls(canvas_active_enrollments, schedule,
"""
Set canvas_course_url in schedule.sections
"""
now = get_comparison_datetime(request)
section_labels = set()
canvas_sis_ids = {}
# MUWM-5362 {canvas_section_sis_id: primary_section_label}
for section in schedule.sections:
section_labels.add(section.section_label())
section_label = section.section_label()

canvas_links = {} # sis_course_id: canvas course_url
for enrollment in canvas_active_enrollments:
(sws_label, inst_regid) = sws_section_label(enrollment.sis_course_id)
if sws_label is not None and sws_label in section_labels:
sis_course_id = enrollment.sis_course_id
if sis_course_id not in canvas_links:
canvas_links[sis_course_id] = enrollment.course_url

for section in schedule.sections:
try:
section.canvas_course_url = canvas_links.get(
section.canvas_course_sis_id())
cid = section.canvas_course_sis_id()
if cid not in canvas_sis_ids:
canvas_sis_ids[cid] = section.primary_section_label()
except InvalidCanvasIndependentStudyCourse as ex:
# REQ3132940 known SWS issue:
# prior quarter's registration data has
# no independent study instructor.
# If independent_study_instructor being None occurs
# in current or future quarter, likely is a data error.
if not section.term.is_past(now):
log_err(logger,
"{} {}".format(section.section_label(), ex),
traceback, request)
pass
log_err(
logger, f"canvas_course_sis_id of {section_label} {ex}",
traceback, request)
continue
try:
cid = section.canvas_section_sis_id()
canvas_sis_ids[cid] = section.primary_section_label()
except Exception as ex:
log_err(
logger, f"canvas_section_sis_id of {section_label} {ex}",
traceback, request)
logger.debug({'canvas_sis_ids': canvas_sis_ids})

canvas_links = {} # primary_section_label: canvas course_url
for enrollment in canvas_active_enrollments:
psection_label = None
# MUWM-5362 check both course and section
if enrollment.sis_section_id in canvas_sis_ids:
psection_label = canvas_sis_ids[enrollment.sis_section_id]
else:
if enrollment.sis_course_id in canvas_sis_ids:
psection_label = canvas_sis_ids[enrollment.sis_course_id]
if psection_label and psection_label not in canvas_links:
canvas_links[psection_label] = enrollment.course_url
logger.debug({'canvas_links': canvas_links})

for section in schedule.sections:
section.canvas_course_url = canvas_links.get(
section.primary_section_label())


def get_canvas_course_from_section(sws_section):
Expand All @@ -91,12 +111,11 @@ def get_canvas_course_url(sws_section, person):
def sws_section_label(sis_id):
canvas_section = CanvasSection(sis_section_id=sis_id)
sws_label = canvas_section.sws_section_id()
if sws_label is None:
canvas_course = CanvasCourse(sis_course_id=sis_id)
sws_label = canvas_course.sws_course_id()
return (sws_label, canvas_course.sws_instructor_regid())
else:
if sws_label is not None:
return (sws_label, canvas_section.sws_instructor_regid())
canvas_course = CanvasCourse(sis_course_id=sis_id)
sws_label = canvas_course.sws_course_id()
return (sws_label, canvas_course.sws_instructor_regid())


def get_viewable_course_sections(canvas_course_id, canvas_user_id):
Expand All @@ -108,7 +127,7 @@ def get_viewable_course_sections(canvas_course_id, canvas_user_id):
limit_privileges_to_course_section = False
limit_sections = {}

enrollments = Enrollments().get_enrollments_for_course(
enrollments = canvas_enrollments.get_enrollments_for_course(
canvas_course_id, params={'user_id': canvas_user_id})

for enrollment in enrollments:
Expand Down
2 changes: 1 addition & 1 deletion myuw/data/category_links_import.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Category,Subcategory,affiliation,Central (not campus specific),Central Title,Seattle,Seattle (link text),Bothell (destination URL),Bothell (link text),Tacoma,Tacoma Title,Open in a new tab?,,,,,,,,,,,,,
PageAcademics,Online Learning,all,,,https://academicsupport.uw.edu/online-learning/,Online Learning Tips and Resources,,,,,no,,,,,,,,,,,,,
PageAcademics,Online Learning,all,,,https://academicsupport.uw.edu/study-skills/online-learning/,Online Learning Resources,,,,,no,,,,,,,,,,,,,
PageAcademics,Online Learning,all,,,,,https://www.uwb.edu/it/learning,Student Help for Learning Online,,,no,,,,,,,,,,,,,
PageAcademics,Online Learning,all,,,,,https://www.uwb.edu/academic-support-programs/,Academic Support Services,,,no,,,,,,,,,,,,,
PageAcademics,Online Learning,all,,,,,https://www.uwb.edu/it/service-catalog/teaching-learning/tech-lending-program,Laptop and WiFi Hotspot Lending Program,,,no,,,,,,,,,,,,,
Expand Down
2 changes: 1 addition & 1 deletion myuw/data/resource_link_import.csv
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Campus Life,Campus Safety,all,http://www.washington.edu/safecampus/,SafeCampus,,
Campus Life,Campus Safety,all,,,https://www.ehs.washington.edu/,Environmental Health & Safety,https://www.uwb.edu/safety/ehs-emergency/environment-health-safety,Environmental Health & Safety,https://www.tacoma.uw.edu/fa/environmental-health-safety,Environmental Health & Safety,no
Campus Life,Campus Safety,all,https://mychem.ehs.washington.edu/,MyChem,,,,,,,no
Campus Life,Campus Safety,all,,,https://www.washington.edu/uwem/,UW Emergency Management,https://www.uwb.edu/emergency,UW Bothell Emergency Page,https://www.tacoma.uw.edu/fa/safety/emergency-preparedness,UW Tacoma Emergency Response,no
Campus Life,Getting Around Campus,all,,,http://www.washington.edu/maps/,Campus Map,https://www.uwb.edu/wp-content/uploads/2024/04/uw-bothell-campus-map.pdf,Campus Map,http://www.tacoma.uw.edu/campus-map/campus-map,Campus Map,no
Campus Life,Getting Around Campus,all,,,http://www.washington.edu/maps/,Campus Map,https://www.uwb.edu/about/directions,Campus Map,http://www.tacoma.uw.edu/campus-map/campus-map,Campus Map,no
Campus Life,Getting Around Campus,all,,,https://transportation.uw.edu/getting-here,Getting to Seattle Campus,http://www.uwb.edu/visitors/directions,Getting to UW Bothell Campus,https://www.tacoma.uw.edu/fa/facilities/transportation/parking-and-transportation-resources#permalink-19448,Getting to UW Tacoma Campus,no
Campus Life,Getting Around Campus,all,,,https://transportation.uw.edu/getting-here/transit/u-pass#u-pass-students,U-PASS for Students,https://www.uwb.edu/commuter-services/transportation/upass,U-PASS,https://www.tacoma.uw.edu/uwt/fa/facilities/transportation/u-pass,U-PASS,no
Campus Life,Getting Around Campus,all,,,https://transportation.uw.edu/getting-here/transit/u-pass#u-pass-faculty-staff,U-PASS for Employees,,,,,no
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"Current": {
"Address": null,
"AlumAffiliationState": null,
"ChangedSinceDate": null,
"Department": null,
"DevelopmentID": null,
"DisplayName": null,
"EduPersonAffiliationAffiliate": false,
"EduPersonAffiliationAlum": false,
"EduPersonAffiliationEmployee": false,
"EduPersonAffiliationFaculty": false,
"EduPersonAffiliationMember": false,
"EduPersonAffiliationStaff": false,
"EduPersonAffiliationStudent": false,
"Email": null,
"EmployeeAffiliationState": null,
"EmployeeID": null,
"FirstName": null,
"HomeDepartment": null,
"Href": "/identity/v2/person.json?uwregid=&uwnetid=&employee_id=&student_number=1033334&student_system_key=&development_id=&last_name=&first_name=&display_name=&edupersonaffiliation_student=&edupersonaffiliation_staff=&edupersonaffiliation_faculty=&edupersonaffiliation_employee=&edupersonaffiliation_member=&edupersonaffiliation_alum=&edupersonaffiliation_affiliate=&changed_since_date=&phone_number=&mail_stop=&home_dept=&department=&address=&title=&email=&alumAffiliationState=&employeeAffiliationState=&studentAffiliationState=&verbose=on&page_size=10&page_start=1",
"LastName": null,
"MailStop": null,
"PageSize": "10",
"PageStart": "1",
"PhoneNumber": null,
"StudentAffiliationState": null,
"StudentNumber": "1033334",
"StudentSystemKey": null,
"Title": null,
"UWNetID": null,
"UWRegID": null,
"Verbose": true
},
"Next": null,
"PageSize": "10",
"PageStart": "1",
"Persons": [
{
"DisplayName": "Jamesian McMiddle Average",
"EduPersonAffiliations": [
"alum",
"employee",
"member",
"staff",
"student"
],
"IsTestEntity": true,
"PersonAffiliations": {
"AlumPersonAffiliation": {
"AlumAffiliationState": "current",
"DevelopmentID": "0000773877"
},
"EmployeePersonAffiliation": {
"EmployeeAffiliationState": "current",
"EmployeeID": "123456789",
"EmployeeWhitePages": {
"Addresses": [],
"EmailAddresses": [],
"Faxes": [],
"Mobiles": [],
"Name": "Average, Jamesian McMiddle",
"Pagers": [],
"Phones": [],
"Positions": [],
"PublishInDirectory": false,
"TouchDials": [],
"VoiceMails": []
},
"HomeDepartment": "C&C TEST BUDGET",
"MailStop": null
},
"StudentPersonAffiliation": {
"StudentAffiliationState": "current",
"StudentNumber": "1033334",
"StudentSystemKey": "000083856",
"StudentWhitePages": {
"Class": null,
"Departments": [],
"Email": null,
"Name": "Average, Jamesian McMiddle",
"Phone": null,
"PublishInDirectory": false
}
}
},
"PreferredFirstName": "Jamesian",
"PreferredMiddleName": "McMiddle",
"PreferredSurname": "Average",
"PriorUWNetIDs": [],
"PriorUWRegIDs": [],
"Pronouns": "they/them/theirs",
"RegisteredFirstMiddleName": "JAMES AVERAGE",
"RegisteredName": "JAMES AVERAGE STUDENT",
"RegisteredSurname": "STUDENT",
"RepositoryTimeStamp": "6/6/2024 4:53:02 PM",
"UIDNumber": "35443",
"UWNetID": "javerage",
"UWRegID": "9136CCB8F66711D5BE060004AC494FFE",
"WhitepagesPublish": false
}
],
"Previous": null,
"TotalCount": 1
}
Loading

0 comments on commit 340f7d2

Please sign in to comment.