Populate subprocessor filters from server facets
The subprocessors toolbar derived its category and region filter options client-side from a second, unfiltered subprocessors(first: 250) fetch, shipping up to 250 rows purely to compute two small facet sets and silently capping the options at that limit. Expose subprocessorCategories and subprocessorCountries on TrustCenter, each backed by a DISTINCT query over the organization's third parties scoped to show_on_trust_center, and read them directly in the toolbar. The page now issues one filtered list query plus two tiny arrays, and the options only ever include values that can actually return results. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -80,6 +80,64 @@ func (s ThirdPartyService) ListForOrganizationId(
|
||||
return page.NewPage(thirdParties, cursor), nil
|
||||
}
|
||||
|
||||
func (s ThirdPartyService) ListDistinctTrustCenterCategoriesForOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
) ([]coredata.ThirdPartyCategory, error) {
|
||||
var categories []coredata.ThirdPartyCategory
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
thirdParties := &coredata.ThirdParties{}
|
||||
|
||||
result, err := thirdParties.LoadDistinctTrustCenterCategoriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load thirdParty categories: %w", err)
|
||||
}
|
||||
|
||||
categories = result
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return categories, nil
|
||||
}
|
||||
|
||||
func (s ThirdPartyService) ListDistinctTrustCenterCountriesForOrganizationID(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
organizationID gid.GID,
|
||||
) ([]coredata.CountryCode, error) {
|
||||
var countries []coredata.CountryCode
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
ctx,
|
||||
func(ctx context.Context, conn pg.Querier) error {
|
||||
thirdParties := &coredata.ThirdParties{}
|
||||
|
||||
result, err := thirdParties.LoadDistinctTrustCenterCountriesByOrganizationID(ctx, conn, scope, organizationID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot load thirdParty countries: %w", err)
|
||||
}
|
||||
|
||||
countries = result
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return countries, nil
|
||||
}
|
||||
|
||||
func (s ThirdPartyService) CountForTrustCenterId(
|
||||
ctx context.Context,
|
||||
scope coredata.Scoper,
|
||||
|
||||
Reference in New Issue
Block a user