Skip to content

Flag missing project PI/Co-PI in data health; fix get_pis/get_co_pis (#1182)#1337

Merged
jonfroehlich merged 1 commit into
masterfrom
1182-project-pi-copi-data-health
Jun 18, 2026
Merged

Flag missing project PI/Co-PI in data health; fix get_pis/get_co_pis (#1182)#1337
jonfroehlich merged 1 commit into
masterfrom
1182-project-pi-copi-data-health

Conversation

@jonfroehlich

Copy link
Copy Markdown
Member

Summary

Closes #1182.

Adds a read-only project-leadership check to the admin Data Health dashboard and fixes two long-broken Project methods 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.py flags:
    • no PI — project has no ProjectRole marked PI at all.
    • no active PI — project hasn't ended, but every PI role on it has an end date in the past (nobody is currently the PI of a live project).
  • Co-PI absence is intentionally not flagged (many projects legitimately have only a PI); the Co-PI count is surfaced as context.
  • Registered in 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()

  • Both filtered on a nonexistent pi_member field (the real field is lead_project_role), so any call raised FieldError. No callers existed anywhere (.py/.html), so they were dead+broken.
  • Rewrote them to filter on lead_project_role and return a deduplicated QuerySet of Person objects, matching their docstrings. (They previously returned person IDs via values_list; with no callers, returning Person objects as documented is the correct contract.)

Tests

  • ProjectLeadershipCheckTests in test_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.
  • ProjectGetPisCoPisTests in test_project.py: correct PI/Co-PI selection, empty-when-none, dedup of repeated PI roles.
  • Full run green: 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

…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>
@jonfroehlich jonfroehlich merged commit 116fd79 into master Jun 18, 2026
2 checks passed
@jonfroehlich jonfroehlich deleted the 1182-project-pi-copi-data-health branch June 18, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go through and check project PI and Co-PI info

1 participant