diff --git a/hub/graphql/types/model_types.py b/hub/graphql/types/model_types.py index b669a869c..ba44f2afe 100644 --- a/hub/graphql/types/model_types.py +++ b/hub/graphql/types/model_types.py @@ -1591,6 +1591,7 @@ def statistics_for_choropleth( # they're gonna all be geo-joined for now. stats_config: stats.StatisticsConfig, choropleth_config: Optional[stats.ChoroplethConfig] = None, + map_bounds: Optional[stats.MapBounds] = None, ) -> List[GroupedDataCount]: choropleth_config = choropleth_config or stats.ChoroplethConfig() @@ -1625,9 +1626,7 @@ def statistics_for_choropleth( return ( stats.statistics( - stats_config, - choropleth_config, - as_grouped_data=True, + stats_config, choropleth_config, as_grouped_data=True, map_bounds=map_bounds ) or [] ) # Convert None to empty list for better front-end integration diff --git a/hub/graphql/types/stats.py b/hub/graphql/types/stats.py index 5e75d8809..6413c4c08 100644 --- a/hub/graphql/types/stats.py +++ b/hub/graphql/types/stats.py @@ -182,7 +182,6 @@ class ChoroplethConfig: category_key: Optional[str] = None count_key: Optional[str] = None is_count_key_percentage: Optional[bool] = False - map_bounds: Optional[MapBounds] = None def statistics( @@ -190,6 +189,7 @@ def statistics( choropleth_config: Optional[ChoroplethConfig] = None, as_grouped_data: bool = False, return_numeric_keys_only: Optional[bool] = False, + map_bounds: Optional[MapBounds] = None, ): choropleth_config = choropleth_config or ChoroplethConfig() @@ -227,8 +227,7 @@ def statistics( # Actual SELECT statement is manually constructed below qs = models.GenericData.objects.values_list("id") - if choropleth_config.map_bounds: - map_bounds = choropleth_config.map_bounds + if map_bounds: bbox_coords = ( (map_bounds.west, map_bounds.north), # Top left (map_bounds.east, map_bounds.north), # Top right diff --git a/nextjs/src/__generated__/gql.ts b/nextjs/src/__generated__/gql.ts index 748366371..e74fed32a 100644 --- a/nextjs/src/__generated__/gql.ts +++ b/nextjs/src/__generated__/gql.ts @@ -70,7 +70,7 @@ const documents = { "\n mutation UpdateMapReport($input: MapReportInput!) {\n updateMapReport(data: $input) {\n id\n name\n displayOptions\n layers {\n id\n name\n source\n sourceData {\n id\n name\n }\n inspectorType\n inspectorConfig\n mapboxPaint\n mapboxLayout\n }\n }\n }\n": types.UpdateMapReportDocument, "\n mutation DeleteMapReport($id: IDObject!) {\n deleteMapReport(data: $id) {\n id\n }\n }\n": types.DeleteMapReportDocument, "\n query GetMapReportName($id: ID!) {\n mapReport(id: $id) {\n id\n name\n }\n }\n": types.GetMapReportNameDocument, - "\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n": types.StatisticsDocument, + "\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n $mapBounds: MapBounds\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n mapBounds: $mapBounds\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n": types.StatisticsDocument, "\n query StatisticsTable($config: StatisticsConfig!) {\n statistics(statsConfig: $config)\n }\n": types.StatisticsTableDocument, "\n query SourceMetadata($sourceId: ID!) {\n externalDataSource(id: $sourceId) {\n fieldDefinitions {\n externalId\n value\n label\n }\n }\n }\n": types.SourceMetadataDocument, "\n mutation WebhookRefresh($ID: String!) {\n refreshWebhooks(externalDataSourceId: $ID) {\n id\n hasWebhooks\n automatedWebhooks\n webhookHealthcheck\n }\n }\n": types.WebhookRefreshDocument, @@ -341,7 +341,7 @@ export function gql(source: "\n query GetMapReportName($id: ID!) {\n mapRepo /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n"): (typeof documents)["\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n"]; +export function gql(source: "\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n $mapBounds: MapBounds\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n mapBounds: $mapBounds\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n"): (typeof documents)["\n query Statistics(\n $config: StatisticsConfig!\n $choroplethConfig: ChoroplethConfig!\n $mapBounds: MapBounds\n ) {\n statisticsForChoropleth(\n statsConfig: $config\n choroplethConfig: $choroplethConfig\n mapBounds: $mapBounds\n ) {\n label\n gss\n count\n formattedCount\n category\n columns\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/nextjs/src/__generated__/graphql.ts b/nextjs/src/__generated__/graphql.ts index 10640fcae..a137878fa 100644 --- a/nextjs/src/__generated__/graphql.ts +++ b/nextjs/src/__generated__/graphql.ts @@ -630,7 +630,6 @@ export type ChoroplethConfig = { categoryKey?: InputMaybe; countKey?: InputMaybe; isCountKeyPercentage?: InputMaybe; - mapBounds?: InputMaybe; }; export type CommonData = { @@ -2673,6 +2672,7 @@ export type QueryStatisticsArgs = { export type QueryStatisticsForChoroplethArgs = { choroplethConfig?: InputMaybe; + mapBounds?: InputMaybe; statsConfig: StatisticsConfig; }; @@ -3725,6 +3725,7 @@ export type GetMapReportNameQuery = { __typename?: 'Query', mapReport: { __typen export type StatisticsQueryVariables = Exact<{ config: StatisticsConfig; choroplethConfig: ChoroplethConfig; + mapBounds?: InputMaybe; }>; @@ -3969,7 +3970,7 @@ export const PatchMapReportDocument = {"kind":"Document","definitions":[{"kind": export const UpdateMapReportDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateMapReport"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"MapReportInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateMapReport"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayOptions"}},{"kind":"Field","name":{"kind":"Name","value":"layers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"source"}},{"kind":"Field","name":{"kind":"Name","value":"sourceData"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"inspectorType"}},{"kind":"Field","name":{"kind":"Name","value":"inspectorConfig"}},{"kind":"Field","name":{"kind":"Name","value":"mapboxPaint"}},{"kind":"Field","name":{"kind":"Name","value":"mapboxLayout"}}]}}]}}]}}]} as unknown as DocumentNode; export const DeleteMapReportDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteMapReport"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"IDObject"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteMapReport"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}}]}}]}}]} as unknown as DocumentNode; export const GetMapReportNameDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetMapReportName"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"mapReport"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; -export const StatisticsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Statistics"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"config"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StatisticsConfig"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"choroplethConfig"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ChoroplethConfig"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"statisticsForChoropleth"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statsConfig"},"value":{"kind":"Variable","name":{"kind":"Name","value":"config"}}},{"kind":"Argument","name":{"kind":"Name","value":"choroplethConfig"},"value":{"kind":"Variable","name":{"kind":"Name","value":"choroplethConfig"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"gss"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"formattedCount"}},{"kind":"Field","name":{"kind":"Name","value":"category"}},{"kind":"Field","name":{"kind":"Name","value":"columns"}}]}}]}}]} as unknown as DocumentNode; +export const StatisticsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Statistics"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"config"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StatisticsConfig"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"choroplethConfig"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ChoroplethConfig"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"mapBounds"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"MapBounds"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"statisticsForChoropleth"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statsConfig"},"value":{"kind":"Variable","name":{"kind":"Name","value":"config"}}},{"kind":"Argument","name":{"kind":"Name","value":"choroplethConfig"},"value":{"kind":"Variable","name":{"kind":"Name","value":"choroplethConfig"}}},{"kind":"Argument","name":{"kind":"Name","value":"mapBounds"},"value":{"kind":"Variable","name":{"kind":"Name","value":"mapBounds"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"gss"}},{"kind":"Field","name":{"kind":"Name","value":"count"}},{"kind":"Field","name":{"kind":"Name","value":"formattedCount"}},{"kind":"Field","name":{"kind":"Name","value":"category"}},{"kind":"Field","name":{"kind":"Name","value":"columns"}}]}}]}}]} as unknown as DocumentNode; export const StatisticsTableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"StatisticsTable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"config"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"StatisticsConfig"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"statistics"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"statsConfig"},"value":{"kind":"Variable","name":{"kind":"Name","value":"config"}}}]}]}}]} as unknown as DocumentNode; export const SourceMetadataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"SourceMetadata"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"sourceId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"ID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"externalDataSource"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"sourceId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"fieldDefinitions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"externalId"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"label"}}]}}]}}]}}]} as unknown as DocumentNode; export const WebhookRefreshDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"WebhookRefresh"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"ID"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"refreshWebhooks"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"externalDataSourceId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"ID"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasWebhooks"}},{"kind":"Field","name":{"kind":"Name","value":"automatedWebhooks"}},{"kind":"Field","name":{"kind":"Name","value":"webhookHealthcheck"}}]}}]}}]} as unknown as DocumentNode; diff --git a/nextjs/src/__generated__/zodSchema.ts b/nextjs/src/__generated__/zodSchema.ts index 687f544eb..193ae542e 100644 --- a/nextjs/src/__generated__/zodSchema.ts +++ b/nextjs/src/__generated__/zodSchema.ts @@ -146,8 +146,7 @@ export function ChoroplethConfigSchema(): z.ZodObject