diff --git a/database/migrations/functions/packages/get_package.sql b/database/migrations/functions/packages/get_package.sql index 8737f9170..e47e9bb86 100644 --- a/database/migrations/functions/packages/get_package.sql +++ b/database/migrations/functions/packages/get_package.sql @@ -97,20 +97,9 @@ begin 'subscriptions', (select count(*) from subscription where package_id = v_package_id), 'webhooks', (select count(*) from webhook__package where package_id = v_package_id) ), - 'production_organizations', ( - select json_agg(json_build_object( - 'name', o.name, - 'display_name', o.display_name, - 'home_url', o.home_url, - 'logo_image_id', o.logo_image_id - )) - from ( - select o.name, o.display_name, o.home_url, o.logo_image_id - from production_usage pu - join organization o using (organization_id) - where pu.package_id = v_package_id - order by o.name asc - ) o + 'production_organizations_count', ( + select count(*) from production_usage + where package_id = v_package_id ) )) from package p diff --git a/database/tests/functions/packages/get_package.sql b/database/tests/functions/packages/get_package.sql index d8796d320..975aec4d0 100644 --- a/database/tests/functions/packages/get_package.sql +++ b/database/tests/functions/packages/get_package.sql @@ -377,14 +377,7 @@ select is( "subscriptions": 1, "webhooks": 0 }, - "production_organizations": [ - { - "name": "org2", - "display_name": "Organization 2", - "home_url": "https://org2.com", - "logo_image_id": "00000000-0000-0000-0000-000000000003" - } - ] + "production_organizations_count": 1 }'::jsonb, 'Last package1 version is returned as a json object' ); @@ -530,14 +523,7 @@ select is( "subscriptions": 1, "webhooks": 0 }, - "production_organizations": [ - { - "name": "org2", - "display_name": "Organization 2", - "home_url": "https://org2.com", - "logo_image_id": "00000000-0000-0000-0000-000000000003" - } - ] + "production_organizations_count": 1 }'::jsonb, 'Last package1 version is returned as a json object' ); @@ -633,14 +619,7 @@ select is( "subscriptions": 1, "webhooks": 0 }, - "production_organizations": [ - { - "name": "org2", - "display_name": "Organization 2", - "home_url": "https://org2.com", - "logo_image_id": "00000000-0000-0000-0000-000000000003" - } - ] + "production_organizations_count": 1 }'::jsonb, 'Requested package version is returned as a json object' ); @@ -688,7 +667,8 @@ select is( "stats": { "subscriptions": 0, "webhooks": 1 - } + }, + "production_organizations_count": 0 }'::jsonb, 'Last package2 version is returned as a json object' ); diff --git a/web/src/layout/common/ProductionBadge.test.tsx b/web/src/layout/common/ProductionBadge.test.tsx index 17c48ab84..31b6a7757 100644 --- a/web/src/layout/common/ProductionBadge.test.tsx +++ b/web/src/layout/common/ProductionBadge.test.tsx @@ -15,7 +15,7 @@ describe('VerifiedPublisherBadge', () => { it('renders label', async () => { render(); - expect(screen.getByText('In Production')).toBeInTheDocument(); + expect(screen.getByText('Production users')).toBeInTheDocument(); const badge = screen.getByTestId('elementWithTooltip'); expect(badge).toBeInTheDocument(); @@ -28,7 +28,7 @@ describe('VerifiedPublisherBadge', () => { it('renders label with tooltip msg in singular', async () => { render(); - expect(screen.getByText('In Production')).toBeInTheDocument(); + expect(screen.getByText('Production users')).toBeInTheDocument(); const badge = screen.getByTestId('elementWithTooltip'); expect(badge).toBeInTheDocument(); diff --git a/web/src/layout/common/ProductionBadge.tsx b/web/src/layout/common/ProductionBadge.tsx index c38554d98..ff9dd221d 100644 --- a/web/src/layout/common/ProductionBadge.tsx +++ b/web/src/layout/common/ProductionBadge.tsx @@ -14,7 +14,7 @@ const ProductionBadge = (props: Props) => { return ( } iconLegend={props.productionOrganizationsCount} />} + element={