Skip to content

Commit f4867b5

Browse files
WarrenWarren
authored andcommitted
added report level ai analysis
1 parent f2a8ef1 commit f4867b5

File tree

12 files changed

+433
-110
lines changed

12 files changed

+433
-110
lines changed

frontend/src/cards/CardWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { Fips } from '../data/utils/Fips'
99
import { SHOW_INSIGHT_GENERATION } from '../featureFlags'
1010
import type { ScrollableHashId } from '../utils/hooks/useStepObserver'
1111
import CardOptionsMenu from './ui/CardOptionsMenu'
12-
import InsightDisplay from './ui/InsightDisplay'
12+
import InsightCard from './ui/InsightCard'
1313
import { Sources } from './ui/Sources'
1414

1515
function CardWrapper(props: {
@@ -63,7 +63,7 @@ function CardWrapper(props: {
6363
className={`relative m-2 rounded-sm bg-white p-3 shadow-raised ${props.className}`}
6464
>
6565
{shouldShowInsightDisplay && (
66-
<InsightDisplay
66+
<InsightCard
6767
demographicType={props.demographicType}
6868
metricIds={props.metricIds}
6969
queryResponses={queryResponses}

frontend/src/cards/generateInsightsUtils.tsx

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import type { MetricQueryResponse } from '../../data/query/MetricQuery'
1212
import { splitIntoKnownsAndUnknowns } from '../../data/utils/datasetutils'
1313
import type { Fips } from '../../data/utils/Fips'
1414
import { SHOW_INSIGHT_GENERATION } from '../../featureFlags'
15+
import { generateCardInsight } from '../../utils/generateCardInsight'
1516
import type { ScrollableHashId } from '../../utils/hooks/useStepObserver'
16-
import { generateInsight } from '../generateInsights'
1717

18-
type InsightDisplayProps = {
18+
type InsightCardProps = {
1919
demographicType: DemographicType
2020
metricIds: MetricId[]
2121
queryResponses: MetricQueryResponse[]
@@ -24,7 +24,7 @@ type InsightDisplayProps = {
2424
fips?: Fips
2525
}
2626

27-
const InsightDisplay: React.FC<InsightDisplayProps> = ({
27+
const InsightCard: React.FC<InsightCardProps> = ({
2828
queryResponses,
2929
shareConfig,
3030
demographicType,
@@ -46,7 +46,7 @@ const InsightDisplay: React.FC<InsightDisplayProps> = ({
4646

4747
setIsGeneratingInsight(true)
4848
try {
49-
const result = await generateInsight(
49+
const result = await generateCardInsight(
5050
{ knownData, metricIds },
5151
hashId,
5252
fips
@@ -92,4 +92,4 @@ const InsightDisplay: React.FC<InsightDisplayProps> = ({
9292
)
9393
}
9494

95-
export default InsightDisplay
95+
export default InsightCard

frontend/src/pages/ExploreData/ExploreDataPage.tsx

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
import { useAtomValue } from 'jotai'
2-
import { lazy, useCallback, useEffect, useState } from 'react'
3-
import { STATUS } from 'react-joyride-react-19' // TODO: ideally revert back to react-joyride and not this temporary fork
4-
import { useLocation } from 'react-router'
1+
import { useAtomValue } from 'jotai';
2+
import { lazy, useCallback, useEffect, useState } from 'react';
3+
import { STATUS } from 'react-joyride-react-19'; // TODO: ideally revert back to react-joyride and not this temporary fork
4+
import { useLocation } from 'react-router';
55
import {
6-
type DropdownVarId,
7-
isDropdownVarId,
8-
} from '../../data/config/DropDownIds'
9-
import { METRIC_CONFIG } from '../../data/config/MetricConfig'
6+
isDropdownVarId, type DropdownVarId
7+
} from '../../data/config/DropDownIds';
8+
import { METRIC_CONFIG } from '../../data/config/MetricConfig';
109
import type {
1110
DataTypeConfig,
12-
DataTypeId,
13-
} from '../../data/config/MetricConfigTypes'
14-
import { INCARCERATION_IDS } from '../../data/providers/IncarcerationProvider'
15-
import { ALL } from '../../data/utils/Constants'
16-
import ReportProvider from '../../reports/ReportProvider'
17-
import { LIFELINE_IDS } from '../../reports/ui/LifelineAlert'
18-
import { srSpeak } from '../../utils/a11yutils'
19-
import { urlMap } from '../../utils/externalUrls'
20-
import useDeprecatedParamRedirects from '../../utils/hooks/useDeprecatedParamRedirects'
21-
import { useHeaderScrollMargin } from '../../utils/hooks/useHeaderScrollMargin'
11+
DataTypeId
12+
} from '../../data/config/MetricConfigTypes';
13+
import { INCARCERATION_IDS } from '../../data/providers/IncarcerationProvider';
14+
import { ALL } from '../../data/utils/Constants';
15+
import ReportProvider from '../../reports/ReportProvider';
16+
import { LIFELINE_IDS } from '../../reports/ui/LifelineAlert';
17+
import { srSpeak } from '../../utils/a11yutils';
18+
import { urlMap } from '../../utils/externalUrls';
19+
import useDeprecatedParamRedirects from '../../utils/hooks/useDeprecatedParamRedirects';
20+
import { useHeaderScrollMargin } from '../../utils/hooks/useHeaderScrollMargin';
2221
import {
2322
getMadLibPhraseText,
2423
getSelectedConditions,
2524
MADLIB_LIST,
2625
type MadLib,
2726
type MadLibId,
2827
type PhraseSegment,
29-
type PhraseSelections,
30-
} from '../../utils/MadLibs'
28+
type PhraseSelections
29+
} from '../../utils/MadLibs';
3130
import {
3231
selectedDataTypeConfig1Atom,
33-
selectedDataTypeConfig2Atom,
34-
} from '../../utils/sharedSettingsState'
32+
selectedDataTypeConfig2Atom
33+
} from '../../utils/sharedSettingsState';
3534
import {
3635
DATA_TYPE_1_PARAM,
3736
DATA_TYPE_2_PARAM,
@@ -41,17 +40,15 @@ import {
4140
MAP1_GROUP_PARAM,
4241
MAP2_GROUP_PARAM,
4342
parseMls,
44-
psSubscribe,
45-
SHOW_ONBOARDING_PARAM,
46-
setParameter,
47-
setParameters,
48-
stringifyMls,
49-
} from '../../utils/urlutils'
50-
import CHLPMapsModal from './CHLPMapsModal'
51-
import DefaultHelperBox from './DefaultHelperBox'
52-
import MadLibUI from './MadLibUI'
53-
import TopicInfoModal from './TopicInfoModal'
54-
import VoteDotOrgModal from './VoteDotOrgModal'
43+
psSubscribe, setParameter,
44+
setParameters, SHOW_ONBOARDING_PARAM, stringifyMls
45+
} from '../../utils/urlutils';
46+
import CHLPMapsModal from './CHLPMapsModal';
47+
import DefaultHelperBox from './DefaultHelperBox';
48+
import InsightReportModal from './InsightReportModal';
49+
import MadLibUI from './MadLibUI';
50+
import TopicInfoModal from './TopicInfoModal';
51+
import VoteDotOrgModal from './VoteDotOrgModal';
5552

5653
const Onboarding = lazy(async () => await import('./Onboarding'))
5754

@@ -330,6 +327,7 @@ function ExploreDataPage(props: ExploreDataPageProps) {
330327
<TopicInfoModal />
331328
<VoteDotOrgModal />
332329
<CHLPMapsModal />
330+
<InsightReportModal/>
333331
<Onboarding
334332
callback={onboardingCallback}
335333
activelyOnboarding={activelyOnboarding}

0 commit comments

Comments
 (0)