[PM-36965] feat: Add CSV export of cohort to cohort management table#7847
Conversation
Adds an "Export CSV" action to the Admin Portal cohort management UI that streams every organization assigned to a migration cohort as a CSV. Gated by the existing Tools_ManagePlanMigrationCohorts permission and the PM35215_BusinessPlanPriceMigration feature flag. The response is streamed directly to the body rather than buffered, so large cohorts (thousands of orgs) export without loading every row into memory. The repository exposes a bounded keyset page (GetExportRowsByCohortIdAsync) in both the Dapper and EF Core tracks, ordered by (CreationDate, Id) so the new (CohortId, CreationDate, Id) index serves both the seek and the sort.
….csv-export-of-cohort-to-cohort-management-table
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the new Admin Portal CSV export of cohort assignments: the streaming controller endpoint, the No new findings meet the confidence threshold for posting. The change is well-tested (core query paging, controller gates/headers/sanitization, and four-database integration tests) and the security and operability concerns are handled correctly. Code Review DetailsNo findings. Notes on areas examined and cleared:
The automated-bot threads on stream disposal, broad catch, and the nullable |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7847 +/- ##
==========================================
+ Coverage 65.69% 65.72% +0.03%
==========================================
Files 2209 2211 +2
Lines 97750 97904 +154
Branches 8816 8834 +18
==========================================
+ Hits 64216 64347 +131
- Misses 31316 31333 +17
- Partials 2218 2224 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
….csv-export-of-cohort-to-cohort-management-table
|



🎟️ Tracking
PM-36965 — [Determining Eligibility] Add .csv export of cohort to Cohort management table
📔 Objective
Extends the Admin Portal cohort management UI (PM-36951) with an Export CSV action that downloads every organization currently assigned to a migration cohort. This is an internal operator tool for auditing cohort contents and cross-referencing migration lists against external data.
Endpoint:
GET /migration-cohorts/{id}/export→text/csvwithContent-Disposition: attachment, gated by the existingTools_ManagePlanMigrationCohortspermission and thePM35215_BusinessPlanPriceMigrationfeature flag (same gates as the rest of the cohort UI).Columns:
OrganizationId, OrganizationName, AssignedAt, ScheduledDate, MigratedDate.How it works:
GetExportRowsByCohortIdAsyncreturns a bounded keyset page in both ORM tracks (Dapper stored proc + EF Core), ordered by(CreationDate, Id)so the new(CohortId, CreationDate, Id)index serves both the seek and the sort with no residual Sort operator — important because bulk-loaded cohorts share oneCreationDateacross the whole batch.IExportCohortAssignmentsQuery) yields rows asIAsyncEnumerable; the controller owns CSV formatting and HTTP streaming.Safety / operability:
Content-Dispositionheader injection);OrganizationNameis defanged against CSV formula injection.Testing:
CreationDatebulk case.Notes for reviewers:
📸 Screenshots
Internal Admin Portal action (Export CSV link on the cohort list and detail pages); no new design surface — omitted.