Skip to content

Commit 4843cb0

Browse files
committed
fix: PR review requested changes
- Added translation migrations - Created changesets
1 parent c1f350e commit 4843cb0

File tree

5 files changed

+160
-21
lines changed

5 files changed

+160
-21
lines changed

.changeset/flat-horses-compete.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@ifrc-go/ui": patch
3+
---
4+
5+
- Pass styling props to `BarChart` and `TimeSeriesChart`
6+
- Fix date separation logic in `getDatesSeparatedByYear`

.changeset/rotten-ants-help.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"go-web-app": minor
3+
---
4+
5+
Added Operational Learning 2.0
6+
7+
- Key Figures Overview in Operational Learning
8+
- Map View for Operational Learning
9+
- Learning by Sector Bar Chart
10+
- Learning by Region Bar Chart
11+
- Sources Over Time Line Chart
12+
- Methodology changes for the prioritization step
13+
- Added an option to regenerate cached summaries
14+
- Summary post-processing and cleanup
15+
- Enabled MDR code search in admin

app/src/views/OperationalLearning/Stats/OperationalLearningMap/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ interface ClickedPoint {
5353
lngLat: mapboxgl.LngLatLike;
5454
}
5555

56-
const LEARNING_COUNT_LOW_COLOR = '#AEB7C2';
57-
const LEARNING_COUNT_HIGH_COLOR = '#011E41';
56+
const MIN_LEARNING_COUNT = 0;
57+
const LEARNING_COUNT_LOW_COLOR = 'var(--go-ui-color-blue-30)';
58+
const LEARNING_COUNT_HIGH_COLOR = 'var(--go-ui-color-blue-90)';
5859

5960
interface Props {
6061
className?: string;
@@ -86,7 +87,7 @@ function OperationalLearningMap(props: Props) {
8687
}
8788

8889
const features = learningByCountry
89-
?.map((value) => {
90+
.map((value) => {
9091
const country = countriesMap?.[value.country_id];
9192
if (isNotDefined(country)) {
9293
return undefined;
@@ -193,7 +194,7 @@ function OperationalLearningMap(props: Props) {
193194
/>
194195
<div className={styles.labelList}>
195196
<NumberOutput
196-
value={0}
197+
value={MIN_LEARNING_COUNT}
197198
/>
198199
<NumberOutput
199200
value={maxLearning}

app/src/views/OperationalLearning/Stats/index.tsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,24 @@ type SourceTypeEnum = components<'read'>['schemas']['ApiAppealTypeEnumKey'];
7777
const SOURCE_TYPE_EMERGENCY = 1 satisfies SourceTypeEnum;
7878
const SOURCE_TYPE_DREF = 0 satisfies SourceTypeEnum;
7979

80-
const transformSourcesOverTimeData = (data: SourcesOverTimeItem[]) => {
81-
const groupedData: Record<string, Record<SourceType, number>> = {};
82-
83-
data.forEach((entry) => {
80+
const transformSourcesOverTimeData = (data: SourcesOverTimeItem[]) => (
81+
data.reduce<Record<string, Record<SourceType, number>>>((acc, entry) => {
8482
const year = getFormattedDateKey(entry.date);
85-
if (!groupedData[year]) {
86-
groupedData[year] = { dref: 0, emergencyAppeal: 0, others: 0 };
83+
if (isNotDefined(acc[year])) {
84+
acc[year] = { dref: 0, emergencyAppeal: 0, others: 0 };
8785
}
86+
8887
if (entry.atype === SOURCE_TYPE_DREF) {
89-
groupedData[year].dref += entry.count;
88+
acc[year].dref += entry.count;
9089
} else if (entry.atype === SOURCE_TYPE_EMERGENCY) {
91-
groupedData[year].emergencyAppeal += entry.count;
90+
acc[year].emergencyAppeal += entry.count;
9291
} else {
93-
groupedData[year].others += entry.count;
92+
acc[year].others += entry.count;
9493
}
95-
});
9694

97-
return groupedData;
98-
};
95+
return acc;
96+
}, {})
97+
);
9998

10099
interface Props {
101100
query: OpsLearningQuery | undefined
@@ -138,19 +137,23 @@ function Stats(props: Props) {
138137
if (isNotDefined(sourcesOverTimeData)) {
139138
return undefined;
140139
}
140+
141141
const dates = Object.keys(sourcesOverTimeData).map((year) => new Date(year));
142+
143+
if (dates.length < 1) {
144+
return undefined;
145+
}
146+
142147
const oldestDate = new Date(Math.min(...dates.map((date) => date.getTime())));
143148
const latestDate = new Date(Math.max(...dates.map((date) => date.getTime())));
149+
144150
return getDatesSeparatedByYear(oldestDate, latestDate);
145151
}, [sourcesOverTimeData]);
146152

147153
const sourcesOverTimeValueSelector = useCallback(
148154
(key: SourceType, date: Date) => {
149155
const value = sourcesOverTimeData?.[getFormattedDateKey(date)]?.[key];
150-
if (isDefined(value) && value > 0) {
151-
return value;
152-
}
153-
return undefined;
156+
return isDefined(value) && value > 0 ? value : undefined;
154157
},
155158
[sourcesOverTimeData],
156159
);
@@ -177,7 +180,8 @@ function Stats(props: Props) {
177180
strings.sourceOthers,
178181
]);
179182

180-
const activePointData = activePointKey ? sourcesOverTimeData?.[activePointKey] : undefined;
183+
const activePointData = isDefined(activePointKey)
184+
? sourcesOverTimeData?.[activePointKey] : undefined;
181185

182186
return (
183187
<div className={styles.stats}>
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"parent": "000010-1738067954473.json",
3+
"actions": [
4+
{
5+
"action": "add",
6+
"key": "downloadMapTitle",
7+
"namespace": "operationalLearning",
8+
"value": "Operational learning map"
9+
},
10+
{
11+
"action": "add",
12+
"key": "failedToFetchLearning",
13+
"namespace": "operationalLearning",
14+
"value": "Failed to fetch operational learning"
15+
},
16+
{
17+
"action": "add",
18+
"key": "failedToFetchPerComponents",
19+
"namespace": "operationalLearning",
20+
"value": "Failed to fetch PER components"
21+
},
22+
{
23+
"action": "add",
24+
"key": "failedToFetchStats",
25+
"namespace": "operationalLearning",
26+
"value": "Failed To fetch operational learning statistics."
27+
},
28+
{
29+
"action": "add",
30+
"key": "failedToFetchSummary",
31+
"namespace": "operationalLearning",
32+
"value": "Failed to fetch operational learning summary"
33+
},
34+
{
35+
"action": "add",
36+
"key": "learningByRegions",
37+
"namespace": "operationalLearning",
38+
"value": "Learning by regions"
39+
},
40+
{
41+
"action": "add",
42+
"key": "learningBySector",
43+
"namespace": "operationalLearning",
44+
"value": "Learning by sectors"
45+
},
46+
{
47+
"action": "add",
48+
"key": "learningCount",
49+
"namespace": "operationalLearning",
50+
"value": "Learning count"
51+
},
52+
{
53+
"action": "add",
54+
"key": "learningExtract",
55+
"namespace": "operationalLearning",
56+
"value": "Learning Extracts"
57+
},
58+
{
59+
"action": "add",
60+
"key": "operationsIncluded",
61+
"namespace": "operationalLearning",
62+
"value": "Operations Included"
63+
},
64+
{
65+
"action": "add",
66+
"key": "sectorsCovered",
67+
"namespace": "operationalLearning",
68+
"value": "Sectors Covered"
69+
},
70+
{
71+
"action": "add",
72+
"key": "sourceDREF",
73+
"namespace": "operationalLearning",
74+
"value": "DREF"
75+
},
76+
{
77+
"action": "add",
78+
"key": "sourceEmergencyAppeal",
79+
"namespace": "operationalLearning",
80+
"value": "Emergency Appeal"
81+
},
82+
{
83+
"action": "add",
84+
"key": "sourceOthers",
85+
"namespace": "operationalLearning",
86+
"value": "Others"
87+
},
88+
{
89+
"action": "add",
90+
"key": "sourcesOverTime",
91+
"namespace": "operationalLearning",
92+
"value": "Sources over time"
93+
},
94+
{
95+
"action": "add",
96+
"key": "sourcesTypeLegendLabel",
97+
"namespace": "operationalLearning",
98+
"value": "Type of source"
99+
},
100+
{
101+
"action": "add",
102+
"key": "sourcesUsed",
103+
"namespace": "operationalLearning",
104+
"value": "Sources Used"
105+
},
106+
{
107+
"action": "update",
108+
"key": "opsLearningSummariesHeading",
109+
"namespace": "operationalLearning",
110+
"newValue": "Summary of learning"
111+
}
112+
]
113+
}

0 commit comments

Comments
 (0)