Skip to content

Commit

Permalink
Merge branch 'master' into fixMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
gmechali committed Sep 26, 2024
2 parents aa8265f + 329ed3a commit d6a37ce
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 71 deletions.
14 changes: 7 additions & 7 deletions packages/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"typedoc": "^0.25.4",
"vega-embed": "^6.24.0",
"vega-lite": "^5.16.3",
"vite": "^5.2.10"
"vite": "^5.2.14"
},
"dependencies": {
"lodash": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
},
{
"CosineScore": [
0.9296979904174805,
0.8847434520721436
0.9296978712081909,
0.884743332862854
],
"QueryPart": "female population",
"SV": [
Expand All @@ -80,7 +80,7 @@
"Parts": [
{
"CosineScore": [
0.9117770791053772
0.9117770195007324
],
"QueryPart": "male population female",
"SV": [
Expand All @@ -90,7 +90,7 @@
{
"CosineScore": [
0.8982378244400024,
0.8723466396331787
0.8723466992378235
],
"QueryPart": "population",
"SV": [
Expand All @@ -106,10 +106,10 @@
"Parts": [
{
"CosineScore": [
0.8088871836662292,
0.8088873028755188,
0.8034241199493408,
0.8017654418945312,
0.7751556634902954
0.7751557230949402
],
"QueryPart": "male",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"Parts": [
{
"CosineScore": [
0.7997788786888123
0.7997788190841675
],
"QueryPart": "factors like obesity blood pressure asthma impacted",
"SV": [
Expand Down Expand Up @@ -86,7 +86,7 @@
},
{
"CosineScore": [
0.9999996423721313
0.9999995827674866
],
"QueryPart": "blood pressure",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"Parts": [
{
"CosineScore": [
0.8787487149238586
0.8787485361099243
],
"QueryPart": "show climate change",
"SV": [
Expand All @@ -50,7 +50,7 @@
},
{
"CosineScore": [
1.0
0.9999998807907104
],
"QueryPart": "drought",
"SV": [
Expand All @@ -76,7 +76,7 @@
},
{
"CosineScore": [
0.866512656211853
0.8665127754211426
],
"QueryPart": "change drought",
"SV": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/06"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/06"
Expand Down Expand Up @@ -245,8 +244,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/06"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/0649670"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/22035"
Expand Down Expand Up @@ -108,8 +107,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/22035"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/06"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"country/USA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
{
"barTileSpec": {
"maxPlaces": 15,
"maxVariables": 15,
"sort": "DESCENDING"
"maxVariables": 15
},
"comparisonPlaces": [
"geoId/06",
Expand Down
12 changes: 9 additions & 3 deletions server/lib/nl/config_builder/bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import re
from typing import List

from server.config.subject_page_pb2 import BarTileSpec
Expand All @@ -32,6 +33,7 @@

_MAX_VARIABLE_LIMIT = 15
_MAX_PLACES_LIMIT = 15
_SKIP_SORTING_SV_REGEX = r'\d+To\d+'


# Get best date to use for an sv and list of places.
Expand Down Expand Up @@ -120,13 +122,17 @@ def multiple_place_bar_block(column,
def get_sort_order(state: PopulateState, cspec: ChartSpec):
# Use no default sort_order for special DC, since UN
# want the order to be as provided in variable groupings.
sort_order = None if is_special_dc(state.uttr.insight_ctx) \
else BarTileSpec.DESCENDING
sort_order = None if is_special_dc(
state.uttr.insight_ctx) else BarTileSpec.DESCENDING

# If any of the svs in the chart spec are a range, no default sort order
if any([re.search(_SKIP_SORTING_SV_REGEX, sv) for sv in cspec.svs]):
sort_order = None

if (RankingType.LOW in cspec.ranking_types and
RankingType.HIGH not in cspec.ranking_types):
sort_order = BarTileSpec.ASCENDING
elif RankingType.HIGH in cspec.ranking_types:
sort_order = BarTileSpec.DESCENDING

return sort_order
return sort_order
2 changes: 1 addition & 1 deletion server/routes/redirects/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"dc-coverage-aa2": "/tools/visualization#visType%3Dmap%26place%3DEarth%26placeType%3DCountry%26sv%3D%7B%22dcid%22%3A%22Count_Variable_AdministrativeArea2%22%7D",
"video": "https://www.youtube.com/watch?v=O6iVsS-RDYI",
"form": "https://forms.gle/C816TLMyp5fBdDt67",
"DataGemmaPaper": "https://docs.datacommons.org/papers/DataGemma-FullPaper.pdf"
"DataGemmaPaper": "https://arxiv.org/abs/2409.13741"
}
6 changes: 3 additions & 3 deletions static/js/apps/explore/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
} from "../../shared/ga_events";
import { QueryResult, UserMessageInfo } from "../../types/app/explore_types";
import { SubjectPageMetadata } from "../../types/subject_page_types";
import { isPlaceOverviewOnly } from "../../utils/explore_utils";
import { shouldSkipPlaceOverview } from "../../utils/explore_utils";
import { getUpdatedHash } from "../../utils/url_utils";
import { AutoPlay } from "./autoplay";
import { ErrorResult } from "./error_result";
Expand Down Expand Up @@ -209,14 +209,14 @@ export function App(props: { isDemo: boolean }): JSX.Element {
exploreMore: relatedThings["exploreMore"],
mainTopics: relatedThings["mainTopics"],
sessionId: "session" in fulfillData ? fulfillData["session"]["id"] : "",
svSource: fulfillData["svSource"],
};
if (
pageMetadata &&
pageMetadata.pageConfig &&
pageMetadata.pageConfig.categories
) {
// If the response is a single PLACE_OVERVIEW tile, redirect to the place explorer.
if (isPlaceOverviewOnly(pageMetadata)) {
if (shouldSkipPlaceOverview(pageMetadata)) {
const placeDcid = pageMetadata.place.dcid;
const url = `/place/${placeDcid}`;
window.location.replace(url);
Expand Down
10 changes: 7 additions & 3 deletions static/js/apps/explore/success_result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import {
} from "../../shared/context";
import { QueryResult, UserMessageInfo } from "../../types/app/explore_types";
import { SubjectPageMetadata } from "../../types/subject_page_types";
import { isPlaceOverviewOnly } from "../../utils/explore_utils";
import {
isPlaceOverviewOnly,
shouldSkipPlaceOverview,
} from "../../utils/explore_utils";
import { getPlaceTypePlural } from "../../utils/string_utils";
import { trimCategory } from "../../utils/subject_page_utils";
import { getUpdatedHash } from "../../utils/url_utils";
Expand Down Expand Up @@ -108,6 +111,7 @@ export function SuccessResult(props: SuccessResultPropType): JSX.Element {
};
}, []);
const placeOverviewOnly = isPlaceOverviewOnly(props.pageMetadata);
const emptyPlaceOverview = shouldSkipPlaceOverview(props.pageMetadata);
return (
<div
className={`row explore-charts${
Expand Down Expand Up @@ -174,7 +178,7 @@ export function SuccessResult(props: SuccessResultPropType): JSX.Element {
</ExploreContext.Provider>
</NlSessionContext.Provider>
</RankingUnitUrlFuncContext.Provider>
{!isPlaceOverviewOnly(props.pageMetadata) &&
{!emptyPlaceOverview &&
!_.isEmpty(props.pageMetadata.childPlaces) && (
<RelatedPlace
relatedPlaces={props.pageMetadata.childPlaces[childPlaceType]}
Expand All @@ -186,7 +190,7 @@ export function SuccessResult(props: SuccessResultPropType): JSX.Element {
}
></RelatedPlace>
)}
{!isPlaceOverviewOnly(props.pageMetadata) &&
{!emptyPlaceOverview &&
!_.isEmpty(props.pageMetadata.peerPlaces) && (
<RelatedPlace
relatedPlaces={props.pageMetadata.peerPlaces}
Expand Down
6 changes: 1 addition & 5 deletions static/js/components/subject_page/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -667,11 +667,7 @@ function renderTiles(
);
case "PLACE_OVERVIEW":
// TODO(gmechali): Switch to server-side redirection
return tiles.length == 1 ? (
<></>
) : (
<PlaceOverviewTile key={id} place={place} />
);
return <PlaceOverviewTile key={id} place={place} />;
case "ANSWER_MESSAGE":
return (
<AnswerMessageTile
Expand Down
1 change: 1 addition & 0 deletions static/js/types/subject_page_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ export interface SubjectPageMetadata {

mainTopics?: NamedTypedNode[];
sessionId?: string;
svSource?: string;
}
10 changes: 10 additions & 0 deletions static/js/utils/explore_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,13 @@ export function isPlaceOverviewOnly(
// True only if the one tile is of type PLACE_OVERVIEW
return categories[0].blocks[0].columns[0].tiles[0].type === "PLACE_OVERVIEW";
}

// Whether to skip showing the Place Overview tile. It should be skipped if
// place overview is the only tile, and the SvSource was unfulfilled.
export function shouldSkipPlaceOverview(
pageMetadata: SubjectPageMetadata
): boolean {
return (
isPlaceOverviewOnly(pageMetadata) && pageMetadata.svSource !== "UNFULFILLED"
);
}
1 change: 0 additions & 1 deletion static/nodejs_server/mock_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ export const BAR_NL_RESP = {
barTileSpec: {
maxPlaces: 15,
maxVariables: 15,
sort: "DESCENDING",
},
comparisonPlaces: ["geoId/06085"],
statVarKey: [
Expand Down
2 changes: 1 addition & 1 deletion static/nodejs_server/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const TIMELINE_EXPECTED_RESULT = [
const BAR_EXPECTED_RESULT = [
{
chartUrl:
"/nodejs/chart?&props=eJyVlW9v2jAQxr%252BKZe1FJ0WindQ%252F8I5R2jJtbUfYeFFNlXEuiVVjR7ZTgRDffeeEENOiFt5ESXTP7x7fne0VBcWltpA8SsZhsiyA9uhAuCWNKLyCcv5XXACnPVVKGdHCx2FMBnqUdE4vTq%252FOMdQ65v4yUwc%252Brahicx%252FU51zPdcKc0Kpzo3VCRioprTPLVuPz6VK556k2L2Ce7%252FujQVwJG6UXxmBeBQdL11FLT%252BZCkQ6ZMuuA%252FGKKZTBHy2QTfHAyzxEYiNleIS6LQhtXQVvmGJ%252BJqOzstZIZwUvpSgMRudEGfFp8EzYXKovIHebEl8%252BMtJSGsSE0%252BiDlQCsMKLm3dOhKQ03IGiYlr9bGZFM8eygz0O6rzB0w6XIyYAYIUwmJNReYpW8tVpypw7tUgzynRrSEMB12rEwZxxK%252BLXfCOyrJzhYvZ9BNDf8Wqm6Eqqx4gyNlS3OMsY14qwvBI5VqM2fH9CiQ7EyYcTYiQ%252BXAOCaUn8mIjIEbOIruMTuQFrFTRtwQfm5%252Fl8yYZfX6IGRVn1tmyXCBm%252BWoyauBWxzCkNNiwtwPLgfTjuEJLDgUjjyWMyk4qTbr10%252ByVYh90zjBDlm%252Fveui9XE9U5yoXJd2z7xcFd1LdSm7FzLLrkLMHyekcALZH%252Fto4wLxGLD2kqCVBN5mLC66rrAySbvd%252FHJXhJtm6GPrKR1j61jdkJ%252FA3pl%252Fb8UDan0tbVRBjrDCm%252BMQO%252FMxtta8kQTMaa4lWCZhz3rf07bRdXDozegUcMf7YyYiMRe4CJEKHlUlmADPleDB6fWZ7QDXwraYdnT%252BRRR7CHhwpiKjvRWdMTPBH%252FVNt6JztqhuTkt7Z%252BeR%252F8SUgs1k88fisKGF62E8GN5fj%252B5vcVUUL7cCw6xWjfhp50KtsjpZHfPYsUwbnCGiU%252FJDzyzBSy9m2EMykMzg069uSU6%252BrPC6hLXfG66%252Bx7%252F3x3S9%252Fg%252Boqct0",
"/nodejs/chart?&props=eJyVlW1v2jAQx7%252BKZe1FJ0WindQHeMcQXZm2tSNsvKimyjiXxKqxI9upQIjvvnMMxLSohTcoWPf%252F3fkefCsKikttIXuQjMNkWQHt0YFwS5pQeAHl%252FFFaAac9VUuZ0MrboU0BepR1zq%252FOby7R1Drm%252FjITDB9XVLG5N%252Bpzruc6Y05o1bnVOiMjldXWmWWr8f50rdzTVJtnME%252B%252F%252BqNB2gi3Si9MwbwIDpauk5aezYUiHTJl1gH5yRQrYI4hk43x0c48R6AhenuBtK4qbVwDbZlj%252FM1EE87BUAojeC1dbSAht9qAd4tfwpZCFQm5Q5%252F48VEgLWXL2BC2%252BsjlQCs0qLkP6dibxpqYNcxq3tyNyW3y7LHMSHsoM3fApCvJgBkgTGUk1Vygl761mHGmjq9SAHlOQLSE2B1WrM4ZxxS%252BTnfGOyorLhbPF9DNDf8Sq26FakLxAY6Urc0pgW3EO10MHqlcmzk7pUaRZK%252FDjLMJGSoHxjGhfE8mZAzcwEl0j9mDtIi9NOJA%252BL79XTNjls3nvZBNfr4xS4YLHJaTOi8AdziEIafFxL7vXQmmbcMzWHCoHHmoZ1Jw0gzr5w%252B8NYhD3TjBClk%252F3iFpfbzPFDuq1LU90C83VfdaXcvulSyKmxjzxwkpnED2%252B3G0dpF4DJh7STCUDF57rK66rrIyy7vd8npfhEMz9LahS8dYOhYK8gPYm%252BDfhuIBQR%252BkW1XkI87w5jnEyryPDZpXkog5LbUEyyQcuO9b2s46GMexGZ0DTrx%252FZhKScoGXELngSZOCCfBSCR69Xh%252BFHeFa2A7Tts6%252FhGINAR%252FOXBS0t6IzZiZ4EDbdis7ZotmclvYuLhP%252FF10KNpPhZJ1QXGQVHlmttoaPe8uz8eBk86RjdQptsF%252BIzsl3PbMEF1zKsF5kIJnBX3%252BTJTn7tMLVCGs%252FBy7s7K%252F9MV2v%252FwNq8cXq",
data_csv:
'label,Santa Clara County\r\nAccomodation/Food Industry,82881\r\nAdmin / Waste Management Service Industry,60538\r\n"Agriculture, Forestry, Fishing, Hunting",2960\r\nConstruction Industry,53031\r\nEducational Services Industry,81663\r\nHealth Care and Social Assistance Industry,156124\r\nManufacturing,176811\r\nFinance and Insurance Industry,20831\r\nInformation Industry,96168\r\n"Arts, Entertainment, Recreation Industry",20764\r\n"Mining, Quarrying, Oil and Gas Extraction Industry",142\r\nOther Services (except Public Admin),25214\r\nTransportation And Warehousing,20846\r\nUtilities,3527\r\nRetail Trade,72215\r\nReal Estate and Rental and Leasing,15648\r\nPublic Administration,27668\r\nWholesale Trade,28183\r\n"Professional, Scientific, and Technical Services",161223',
dcUrl:
Expand Down
Loading

0 comments on commit d6a37ce

Please sign in to comment.