Skip to content

Commit a487c76

Browse files
committed
BOAC-6260: cohort filter for exceptions to minimum term units
1 parent 148215c commit a487c76

8 files changed

Lines changed: 59 additions & 4 deletions

File tree

bea/fixtures/bea-test-data.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@
283283
{
284284
"status": "Active"
285285
}
286+
],
287+
"min_units_exception_term": [
288+
{
289+
"term": true
290+
}
286291
]
287292
},
288293
{

bea/tests/test_user_role_director.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"""
2525

2626
import pytest
27-
from flask import current_app as app
2827

2928
from bea.config.bea_test_config import BEATestConfig
3029
from bea.models.advisor_role import AdvisorRole
@@ -43,9 +42,6 @@ class TestUserRoleDirector:
4342
director_depts.append(memb)
4443
student = test.test_students[0]
4544
all_notes = test.get_test_notes(student, -1)[0]
46-
app.logger.info(f'{all_notes}')
47-
for note in all_notes:
48-
app.logger.info(f'{vars(note)}')
4945

5046
def test_log_in(self):
5147
self.homepage.load_page()

boac/externals/data_loch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,12 @@ def get_majors():
13241324
return safe_execute_rds(sql)
13251325

13261326

1327+
def get_min_units_exception_terms():
1328+
sql = f"""SELECT DISTINCT term_id FROM {student_schema()}.term_unit_limits
1329+
WHERE min_term_units_allowed <> 0.5"""
1330+
return safe_execute_rds(sql)
1331+
1332+
13271333
def get_minors():
13281334
sql = f"""SELECT min.minor AS minor
13291335
FROM {student_schema()}.student_profile_index spi
@@ -1380,6 +1386,7 @@ def get_students_query( # noqa: C901, PLR0912, PLR0913, PLR0915
13801386
levels=None,
13811387
majors=None,
13821388
midpoint_deficient_grade=None,
1389+
min_units_exception_term=None,
13831390
minors=None,
13841391
scope=(),
13851392
search_phrase=None,
@@ -1559,6 +1566,10 @@ def get_students_query( # noqa: C901, PLR0912, PLR0913, PLR0915
15591566
ON spi.sid = si.sid
15601567
AND si.term_id >= '{earliest_term_id()}'
15611568
AND {_incomplete_criteria(incomplete_date_ranges, incomplete_statuses)}"""
1569+
if min_units_exception_term:
1570+
query_tables += f' LEFT JOIN {student_schema()}.term_unit_limits tul ON tul.sid = spi.sid'
1571+
query_filter += ' AND tul.term_id = ANY(%(min_units_exception_term)s) AND tul.min_term_units_allowed <> 0.5'
1572+
query_bindings.update({'min_units_exception_term': min_units_exception_term})
15621573
if minors:
15631574
query_tables += f' LEFT JOIN {student_schema()}.minors min ON min.sid = spi.sid'
15641575
query_filter += " AND min.minor = ANY(%(minors)s) AND maj.college NOT LIKE 'Graduate%%'"

boac/lib/cohort_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,12 @@ def majors():
252252
return [{'name': major, 'value': major} for major in major_results]
253253

254254

255+
@stow('cohort_filter_options_min_unit_exceptions')
256+
def minimum_unit_exception_terms():
257+
terms_with_exceptions = data_loch.get_min_units_exception_terms()
258+
return [{'name': row['term_id'], 'value': row['term_id']} for row in terms_with_exceptions]
259+
260+
255261
@stow('cohort_filter_options_minors')
256262
def minors():
257263
minor_results = [row['minor'] for row in data_loch.get_minors()]

boac/merged/cohort_filter_options.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
intended_majors,
5353
level_options,
5454
majors,
55+
minimum_unit_exception_terms,
5556
minors,
5657
student_admit_college_options,
5758
student_admit_ethnicity_options,
@@ -260,6 +261,13 @@ def get_all_filter_categories(self):
260261
key='midpointDeficient',
261262
label_primary='Midpoint Deficient Grade',
262263
),
264+
_filter(
265+
key='minUnitsExceptionTerm',
266+
label_primary='Minimum Unit Exception',
267+
options=minimum_unit_exception_terms(),
268+
type_db='string[]',
269+
type_ux='options',
270+
),
263271
_filter(
264272
key='minors',
265273
label_primary='Minor',

boac/merged/student.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def query_students( # noqa: PLR0913
360360
limit=50,
361361
majors=None,
362362
midpoint_deficient_grade=None,
363+
min_units_exception_term=None,
363364
minors=None,
364365
offset=0,
365366
order_by=None,
@@ -427,6 +428,7 @@ def query_students( # noqa: PLR0913
427428
levels=levels,
428429
majors=majors,
429430
midpoint_deficient_grade=midpoint_deficient_grade,
431+
min_units_exception_term=min_units_exception_term,
430432
minors=minors,
431433
scope=scope,
432434
sids=sids,

boac/models/cohort_filter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ def _query_students(
418418
limit=limit,
419419
majors=((criteria.get('majors') or []) + (criteria.get('graduatePrograms') or [])),
420420
midpoint_deficient_grade=criteria.get('midpointDeficient'),
421+
min_units_exception_term=criteria.get('minUnitsExceptionTerm'),
421422
minors=criteria.get('minors'),
422423
offset=offset,
423424
order_by=order_by,

fixtures/loch/loch.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,15 @@ CREATE TABLE student.student_term_gpas
666666
units_taken_for_gpa DECIMAL(4,1)
667667
);
668668

669+
CREATE TABLE student.term_unit_limits
670+
(
671+
sid VARCHAR NOT NULL,
672+
term_id VARCHAR(4) NOT NULL,
673+
min_term_units_allowed DECIMAL (5,3),
674+
max_term_units_allowed DECIMAL (5,3),
675+
PRIMARY KEY (sid, term_id)
676+
);
677+
669678
CREATE TABLE student.visas (
670679
sid VARCHAR,
671680
visa_status VARCHAR,
@@ -2657,6 +2666,23 @@ VALUES
26572666
('3456789012', '2178', 3.2, 15),
26582667
('5678901234', '2178', 2.1, 14);
26592668

2669+
INSERT INTO student.term_unit_limits
2670+
(sid, term_id, min_term_units_allowed, max_term_units_allowed)
2671+
VALUES
2672+
('11667051', '2012', 0.5, 20.5),
2673+
('11667051', '2162', 0.5, 20.5),
2674+
('11667051', '2172', 0.5, 20.5),
2675+
('11667051', '2175', 0.5, 20.5),
2676+
('11667051', '2178', 0.000, 20.5),
2677+
('11667051', '2182', 0.5, 16.000),
2678+
('2345678901', '2172', 0.5, 20.5),
2679+
('2345678901', '2175', 22.000, 22.000 ),
2680+
('3456789012', '2178', 0.5, 20.5),
2681+
('5678901234', '2178', 0.5, 20.5),
2682+
('2718281828', '2058', 0.5, 20.5),
2683+
('2718281828', '2102', 0.5, 20.5),
2684+
('3141592653', '2052', 0.5, 20.5);
2685+
26602686
INSERT INTO student.visas
26612687
(sid, visa_status, visa_type)
26622688
VALUES

0 commit comments

Comments
 (0)