Flag missing project PI/Co-PI in data health; fix get_pis/get_co_pis (#1182)#1337
Merged
Merged
Conversation
…s/get_co_pis (#1182) Add a read-only "project-leadership" data-health check that flags projects with no PI on record, or ongoing projects whose PI role(s) have all ended (no currently-active PI). Co-PI absence is surfaced as context but not flagged, since many projects legitimately have only a PI. Also fix Project.get_pis()/get_co_pis(), which filtered on a nonexistent "pi_member" field (the real field is lead_project_role) and so raised FieldError on any call. They now filter on lead_project_role and return a deduplicated QuerySet of Person objects as their docstrings promise. No callers existed, so changing the return type from person IDs to Person objects is safe. Adds regression tests for the new check and for get_pis/get_co_pis. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1182.
Adds a read-only
project-leadershipcheck to the admin Data Health dashboard and fixes two long-brokenProjectmethods that were almost certainly why "we haven't been tracking [PI/Co-PI] correctly."New data-health check
website/admin/data_health/checks/project_leadership.pyflags:ProjectRolemarked PI at all.checks/__init__.py, so it gets a dashboard row + CSV export for free via the existing registry. Strictly read-only.Bug fix:
Project.get_pis()/get_co_pis()pi_memberfield (the real field islead_project_role), so any call raisedFieldError. No callers existed anywhere (.py/.html), so they were dead+broken.lead_project_roleand return a deduplicatedQuerySetofPersonobjects, matching their docstrings. (They previously returned person IDs viavalues_list; with no callers, returningPersonobjects as documented is the correct contract.)Tests
ProjectLeadershipCheckTestsintest_data_health.py: no-PI flagged, ongoing-with-ended-PI flagged, active-PI not flagged, ended-project-with-ended-PI not flagged; slug added to the read-only mutation guard.ProjectGetPisCoPisTestsintest_project.py: correct PI/Co-PI selection, empty-when-none, dedup of repeated PI roles.python manage.py test website.tests.test_project website.tests.test_data_health --settings=makeabilitylab.settings_test→ 29 tests OK.No public UI change (admin-only data-health + model logic), so no before/after screenshots.
🤖 Generated with Claude Code