Skip to content

Commit b50b5da

Browse files
ewdurbinclaude
andauthored
Organizations Outreach (#18641)
* feat(admin): add organization utilization statistics to dashboard - Added two new ORM queries to track organization utilization metrics - Organizations with projects: count by type (Community/Company) - Organizations with multiple members: count by type - Updated admin dashboard template with new "Organization Utilization" section - Added CSS styling for utilization cards with info tooltips - Updated tests to verify new statistics calculations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * feat: add CLI command to send organization survey emails - Add send_survey_emails command to organizations CLI - Categorize organizations into 4 survey types based on utilization and type - Support dry-run mode for testing without sending emails - Add comprehensive test coverage with 100% code coverage - Integrate with Celery task queue for async email delivery - Add survey email templates with clean HTML styling 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
1 parent e9b70d0 commit b50b5da

File tree

11 files changed

+829
-4
lines changed

11 files changed

+829
-4
lines changed

tests/unit/admin/views/test_core.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from ....common.db.organizations import (
88
OrganizationApplicationFactory,
99
OrganizationFactory,
10+
OrganizationProjectFactory,
1011
OrganizationRoleFactory,
1112
OrganizationStripeSubscriptionFactory,
1213
)
@@ -16,13 +17,31 @@
1617
class TestDashboard:
1718
def test_dashboard(self, db_request):
1819
company_orgs = OrganizationFactory.create_batch(7, orgtype="Company")
19-
OrganizationFactory.create_batch(11, orgtype="Community")
20+
community_orgs = OrganizationFactory.create_batch(11, orgtype="Community")
2021
OrganizationApplicationFactory.create_batch(5, orgtype="Company")
2122
OrganizationApplicationFactory.create_batch(3, orgtype="Community")
2223

23-
for organization in company_orgs:
24+
# Create projects for some organizations
25+
# 3 Company orgs with projects, 5 Community orgs with projects
26+
for organization in company_orgs[:3]:
27+
OrganizationProjectFactory.create(organization=organization)
28+
for organization in community_orgs[:5]:
29+
OrganizationProjectFactory.create(organization=organization)
30+
31+
# Add members to organizations (for testing orgs with multiple members)
32+
# 4 Company orgs with >1 member, 6 Community orgs with >1 member
33+
for organization in company_orgs[:4]:
2434
OrganizationRoleFactory.create_batch(2, organization=organization)
35+
for organization in community_orgs[:6]:
36+
OrganizationRoleFactory.create_batch(2, organization=organization)
37+
38+
# Add single members to some orgs (shouldn't count in multiple members)
39+
for organization in company_orgs[4:6]:
40+
OrganizationRoleFactory.create(organization=organization)
41+
for organization in community_orgs[6:9]:
42+
OrganizationRoleFactory.create(organization=organization)
2543

44+
# Create subscriptions for some company orgs
2645
for organization in company_orgs[:3]:
2746
OrganizationStripeSubscriptionFactory.create(organization=organization)
2847

@@ -34,7 +53,9 @@ def test_dashboard(self, db_request):
3453
"organizations_count": {"Total": 18, "Community": 11, "Company": 7},
3554
"organization_applications_count": {"Total": 8, "submitted": 8},
3655
"active_company_organizations": 3,
37-
"active_company_organization_users": 6,
56+
"active_company_organization_users": 6, # 3 orgs * 2 members
57+
"orgs_with_projects": {"Total": 8, "Community": 5, "Company": 3},
58+
"orgs_with_multiple_members": {"Total": 10, "Community": 6, "Company": 4},
3859
}
3960

4061
assert db_request.has_permission.calls == [
@@ -57,6 +78,8 @@ def test_dashboard_with_permission_and_observation(self, db_request):
5778
"organization_applications_count": {"Total": 0},
5879
"active_company_organizations": 0,
5980
"active_company_organization_users": 0,
81+
"orgs_with_projects": {"Total": 0},
82+
"orgs_with_multiple_members": {"Total": 0},
6083
}
6184
assert db_request.has_permission.calls == [
6285
pretend.call(views.Permissions.AdminObservationsRead),

0 commit comments

Comments
 (0)