-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Admin] Hacker Applicants Overview (#514)
* Added route for getting hacker applicants * Added hacker applicants overview * -Moved admin functions to applicant_review_processor.py -Changed route to /applicants/hackers -Updated test_admin * Explicitly imported applicant_review_processor functions in test_admin * - scoped usage of functions from applicant_review_processor.py - renamed applicant_review_processor function names - moved applicant_review_processor unit tests to new file * - Added placeholder page at /applicants - Removed _omit_reviews - Reverted _process_batch - Moved all applicant_review_processor tests * Merged main into current branch (squash): commit ab1d081 Author: Taesung Hwang <[email protected]> Date: Sun Dec 22 21:37:33 2024 -0800 Refactor user roles from admin site to main site (#519) - Create new enums for user roles for both the admin site and main site - Move status enums from `useApplicant` to the new `userRecord.ts` - Move `isNonHacker` check to `ParticipantAction` - The Portal still needs to be updated to use the new common enums commit c8e1d0c Author: Noah Kim <[email protected]> Date: Sun Dec 22 20:18:15 2024 -0800 Remove Three.js (#498) * update dependencies * Remove other unnecessary dependencies and directories * Minor refactor * Changed enum for useHackerApplicants.ts * Revert "Changed enum for useHackerApplicants.ts" This reverts commit 0d3d887. * Revert "Merged main into current branch (squash):" This reverts commit 92eaa86. * deleted Applicants.tsx * Changed enum for useHackerApplicants.ts
- Loading branch information
1 parent
ab1d081
commit 0b81969
Showing
10 changed files
with
303 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from typing import Any | ||
|
||
from models.ApplicationData import Decision | ||
|
||
|
||
def include_hacker_app_fields( | ||
applicant_record: dict[str, Any], accept_threshold: float, waitlist_threshold: float | ||
) -> None: | ||
_include_decision_based_on_threshold( | ||
applicant_record, accept_threshold, waitlist_threshold | ||
) | ||
_include_num_reviewers(applicant_record) | ||
_include_avg_score(applicant_record) | ||
|
||
|
||
def include_review_decision(applicant_record: dict[str, Any]) -> None: | ||
"""Sets the applicant's decision as the last submitted review decision or None.""" | ||
reviews = applicant_record["application_data"]["reviews"] | ||
applicant_record["decision"] = reviews[-1][2] if reviews else None | ||
|
||
|
||
def _get_last_score(reviewer: str, reviews: list[tuple[str, str, float]]) -> float: | ||
for review in reversed(reviews): | ||
if review[1] == reviewer: | ||
return review[2] | ||
return -1 | ||
|
||
|
||
def _get_avg_score(reviews: list[tuple[str, str, float]]) -> float: | ||
unique_reviewers = {t[1] for t in reviews} | ||
if len(unique_reviewers) < 2: | ||
return -1 | ||
|
||
last_score = _get_last_score(unique_reviewers.pop(), reviews) | ||
last_score2 = _get_last_score(unique_reviewers.pop(), reviews) | ||
return (last_score + last_score2) / 2 | ||
|
||
|
||
def _include_decision_based_on_threshold( | ||
applicant_record: dict[str, Any], accept: float, waitlist: float | ||
) -> None: | ||
avg_score = _get_avg_score(applicant_record["application_data"]["reviews"]) | ||
if avg_score >= accept: | ||
applicant_record["decision"] = Decision.ACCEPTED | ||
elif avg_score >= waitlist: | ||
applicant_record["decision"] = Decision.WAITLISTED | ||
else: | ||
applicant_record["decision"] = Decision.REJECTED | ||
|
||
|
||
def _get_num_unique_reviewers(applicant_record: dict[str, Any]) -> int: | ||
reviews = applicant_record["application_data"]["reviews"] | ||
unique_reviewers = {t[1] for t in reviews} | ||
return len(unique_reviewers) | ||
|
||
|
||
def _include_num_reviewers(applicant_record: dict[str, Any]) -> None: | ||
applicant_record["num_reviewers"] = _get_num_unique_reviewers(applicant_record) | ||
|
||
|
||
def _include_avg_score(applicant_record: dict[str, Any]) -> None: | ||
applicant_record["avg_score"] = _get_avg_score( | ||
applicant_record["application_data"]["reviews"] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from datetime import datetime | ||
|
||
from typing import Any | ||
|
||
from admin import applicant_review_processor | ||
|
||
|
||
def test_no_decision_from_no_reviews() -> None: | ||
"""Test that a decision is None for an applicant with no reviews.""" | ||
record = { | ||
"_id": "edu.uci.pham", | ||
"status": "PENDING_REVIEW", | ||
"application_data": { | ||
"reviews": [], | ||
}, | ||
} | ||
|
||
applicant_review_processor.include_review_decision(record) | ||
assert record["decision"] is None | ||
|
||
|
||
def test_can_include_decision_from_reviews() -> None: | ||
"""Test that a decision can be provided for an applicant with reviews.""" | ||
record = { | ||
"_id": "edu.uci.sydnee", | ||
"status": "REVIEWED", | ||
"application_data": { | ||
"reviews": [[datetime(2023, 1, 19), "edu.uci.alicia", "ACCEPTED"]], | ||
}, | ||
} | ||
|
||
applicant_review_processor.include_review_decision(record) | ||
assert record["decision"] == "ACCEPTED" | ||
|
||
|
||
def test_can_include_num_reviewers_from_reviews() -> None: | ||
"""Test that the number of reviewers are added to an applicant with reviews.""" | ||
record: dict[str, Any] = { | ||
"_id": "edu.uci.sydnee", | ||
"status": "REVIEWED", | ||
"application_data": { | ||
"reviews": [ | ||
[datetime(2023, 1, 19), "edu.uci.alicia", 100], | ||
[datetime(2023, 1, 19), "edu.uci.alicia2", 200], | ||
] | ||
}, | ||
} | ||
|
||
applicant_review_processor._include_num_reviewers(record) | ||
assert record["num_reviewers"] == 2 | ||
|
||
|
||
def test_can_include_avg_score_from_reviews() -> None: | ||
"""Test that an applicant's average score are added to an applicant with reviews.""" | ||
record: dict[str, Any] = { | ||
"_id": "edu.uci.sydnee", | ||
"status": "REVIEWED", | ||
"application_data": { | ||
"reviews": [ | ||
[datetime(2023, 1, 19), "edu.uci.alicia", 10], | ||
[datetime(2023, 1, 19), "edu.uci.alicia2", 0], | ||
[datetime(2023, 1, 19), "edu.uci.alicia", 100], | ||
[datetime(2023, 1, 19), "edu.uci.alicia2", 200], | ||
] | ||
}, | ||
} | ||
|
||
applicant_review_processor._include_avg_score(record) | ||
assert record["avg_score"] == 150 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function ApplicantsSummary() { | ||
return <p>PLACEHOLDER: Various summary charts</p>; | ||
} |
Oops, something went wrong.