Skip to content

Commit 0a68faa

Browse files
authored
Merge pull request #1199 from IFRCGo/fix/appeal-stats
Fix appeals statistics calculation
2 parents a3e0bc8 + d9491a2 commit 0a68faa

File tree

12 files changed

+54
-48
lines changed

12 files changed

+54
-48
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Fix appeals based statistics calculation

app/src/components/domain/ActiveOperationMap/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ function ActiveOperationMap(props: Props) {
181181

182182
return {
183183
...baseQuery,
184-
region: isDefined(regionId) ? [regionId] : undefined,
185-
country: isDefined(countryId) ? [countryId] : undefined,
184+
region: isDefined(regionId) ? regionId : undefined,
185+
country: isDefined(countryId) ? countryId : undefined,
186186
};
187187
},
188188
[variant, regionId, filter, limit, countryId],

app/src/components/domain/AppealsTable/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function AppealsTable(props: Props) {
120120

121121
const columns = useMemo(
122122
() => ([
123-
createDateColumn<AppealListItem, string>(
123+
createDateColumn<AppealListItem, number>(
124124
'start_date',
125125
strings.appealsTableStartDate,
126126
(item) => item.start_date,
@@ -129,7 +129,7 @@ function AppealsTable(props: Props) {
129129
columnClassName: styles.startDate,
130130
},
131131
),
132-
createStringColumn<AppealListItem, string>(
132+
createStringColumn<AppealListItem, number>(
133133
'atype',
134134
strings.appealsTableType,
135135
(item) => item.atype_display,
@@ -138,15 +138,15 @@ function AppealsTable(props: Props) {
138138
columnClassName: styles.appealType,
139139
},
140140
),
141-
createStringColumn<AppealListItem, string>(
141+
createStringColumn<AppealListItem, number>(
142142
'code',
143143
strings.appealsTableCode,
144144
(item) => item.code,
145145
{
146146
columnClassName: styles.code,
147147
},
148148
),
149-
createLinkColumn<AppealListItem, string>(
149+
createLinkColumn<AppealListItem, number>(
150150
'operation',
151151
strings.appealsTableOperation,
152152
(item) => item.name,
@@ -155,13 +155,13 @@ function AppealsTable(props: Props) {
155155
urlParams: { emergencyId: item.event },
156156
}),
157157
),
158-
createStringColumn<AppealListItem, string>(
158+
createStringColumn<AppealListItem, number>(
159159
'dtype',
160160
strings.appealsTableDisastertype,
161161
(item) => item.dtype?.name,
162162
{ sortable: true },
163163
),
164-
createNumberColumn<AppealListItem, string>(
164+
createNumberColumn<AppealListItem, number>(
165165
'amount_requested',
166166
strings.appealsTableRequestedAmount,
167167
(item) => item.amount_requested,
@@ -170,7 +170,7 @@ function AppealsTable(props: Props) {
170170
suffix: ' CHF',
171171
},
172172
),
173-
createProgressColumn<AppealListItem, string>(
173+
createProgressColumn<AppealListItem, number>(
174174
'amount_funded',
175175
strings.appealsTableFundedAmount,
176176
(item) => (
@@ -182,7 +182,7 @@ function AppealsTable(props: Props) {
182182
{ sortable: true },
183183
),
184184
variant !== 'country'
185-
? createLinkColumn<AppealListItem, string>(
185+
? createLinkColumn<AppealListItem, number>(
186186
'country',
187187
strings.appealsTableCountry,
188188
(item) => item.country?.name,
@@ -225,8 +225,8 @@ function AppealsTable(props: Props) {
225225

226226
return {
227227
...baseQuery,
228-
country: isDefined(countryId) ? [countryId] : undefined,
229-
region: isDefined(regionId) ? [regionId] : undefined,
228+
country: isDefined(countryId) ? countryId : undefined,
229+
region: isDefined(regionId) ? regionId : undefined,
230230
};
231231
},
232232
[

app/src/components/domain/RegionKeyFigures/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function RegionKeyFigures(props: Props) {
8787
icon={<FundingCoverageIcon />}
8888
className={styles.keyFigure}
8989
value={getPercentage(
90-
aggregatedAppealResponse?.amount_funded,
91-
aggregatedAppealResponse?.amount_requested,
90+
aggregatedAppealResponse?.amount_funded_dref_included,
91+
aggregatedAppealResponse?.amount_requested_dref_included,
9292
)}
9393
suffix="%"
9494
compactValue

app/src/views/AllAppeals/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ export function Component() {
143143
ordering,
144144
atype: filterAppealType,
145145
dtype: filterDisasterType,
146-
country: isDefined(filterCountry) ? [filterCountry] : undefined,
147-
region: isDefined(filterRegion) ? [filterRegion] : undefined,
146+
country: isDefined(filterCountry) ? filterCountry : undefined,
147+
region: isDefined(filterRegion) ? filterRegion : undefined,
148148
start_date__gte: filter.startDateAfter,
149149
start_date__lte: filter.startDateBefore,
150150
}),
@@ -170,7 +170,7 @@ export function Component() {
170170

171171
const columns = useMemo(
172172
() => ([
173-
createDateColumn<AppealListItem, string>(
173+
createDateColumn<AppealListItem, number>(
174174
'start_date',
175175
strings.allAppealsStartDate,
176176
(item) => item.start_date,
@@ -179,7 +179,7 @@ export function Component() {
179179
columnClassName: styles.startDate,
180180
},
181181
),
182-
createStringColumn<AppealListItem, string>(
182+
createStringColumn<AppealListItem, number>(
183183
'atype',
184184
strings.allAppealsType,
185185
(item) => item.atype_display,
@@ -188,15 +188,15 @@ export function Component() {
188188
columnClassName: styles.appealType,
189189
},
190190
),
191-
createStringColumn<AppealListItem, string>(
191+
createStringColumn<AppealListItem, number>(
192192
'code',
193193
strings.allAppealsCode,
194194
(item) => item.code,
195195
{
196196
columnClassName: styles.code,
197197
},
198198
),
199-
createLinkColumn<AppealListItem, string>(
199+
createLinkColumn<AppealListItem, number>(
200200
'operation',
201201
strings.allAppealsOperation,
202202
(item) => item.name,
@@ -206,12 +206,12 @@ export function Component() {
206206
}),
207207
{ sortable: true },
208208
),
209-
createStringColumn<AppealListItem, string>(
209+
createStringColumn<AppealListItem, number>(
210210
'dtype',
211211
strings.allAppealsDisasterType,
212212
(item) => item.dtype?.name,
213213
),
214-
createNumberColumn<AppealListItem, string>(
214+
createNumberColumn<AppealListItem, number>(
215215
'amount_requested',
216216
strings.allAppealsRequestedAmount,
217217
(item) => item.amount_requested,
@@ -220,7 +220,7 @@ export function Component() {
220220
suffix: ' CHF',
221221
},
222222
),
223-
createProgressColumn<AppealListItem, string>(
223+
createProgressColumn<AppealListItem, number>(
224224
'amount_funded',
225225
strings.allAppealsFundedAmount,
226226
// FIXME: use progress function
@@ -235,7 +235,7 @@ export function Component() {
235235
columnClassName: styles.funding,
236236
},
237237
),
238-
createLinkColumn<AppealListItem, string>(
238+
createLinkColumn<AppealListItem, number>(
239239
'country',
240240
strings.allAppealsCountry,
241241
(item) => item.country?.name,

app/src/views/CountryOngoingActivitiesEmergencies/CountryKeyFigures/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ interface Props {
2222
active_drefs: number | null;
2323
active_appeals: number | null;
2424
target_population: number | null;
25+
amount_requested: number | null;
2526
amount_requested_dref_included: number | null;
2627
amount_funded: number | null;
27-
amount_requested: number | null;
28+
amount_funded_dref_included: number | null;
2829
}
2930
}
3031

@@ -81,8 +82,8 @@ function CountryKeyFigures(props: Props) {
8182
icon={<FundingCoverageIcon />}
8283
className={styles.keyFigure}
8384
value={getPercentage(
84-
data.amount_funded,
85-
data.amount_requested,
85+
data.amount_funded_dref_included,
86+
data.amount_requested_dref_included,
8687
)}
8788
suffix="%"
8889
compactValue

app/src/views/CountryOngoingActivitiesEmergencies/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export function Component(props: BaseProps) {
191191
return {
192192
...baseQuery,
193193
region: undefined,
194-
country: countryId ? [Number(countryId)] : undefined,
194+
country: countryId ? Number(countryId) : undefined,
195195
};
196196
},
197197
[filter, limit, countryId],
@@ -232,7 +232,7 @@ export function Component(props: BaseProps) {
232232

233233
const columns = useMemo(
234234
() => ([
235-
createDateColumn<AppealListItem, string>(
235+
createDateColumn<AppealListItem, number>(
236236
'start_date',
237237
strings.appealsTableStartDate,
238238
(item) => item.start_date,
@@ -241,7 +241,7 @@ export function Component(props: BaseProps) {
241241
columnClassName: styles.startDate,
242242
},
243243
),
244-
createStringColumn<AppealListItem, string>(
244+
createStringColumn<AppealListItem, number>(
245245
'atype',
246246
strings.appealsTableType,
247247
(item) => item.atype_display,
@@ -250,15 +250,15 @@ export function Component(props: BaseProps) {
250250
columnClassName: styles.appealType,
251251
},
252252
),
253-
createStringColumn<AppealListItem, string>(
253+
createStringColumn<AppealListItem, number>(
254254
'code',
255255
strings.appealsTableCode,
256256
(item) => item.code,
257257
{
258258
columnClassName: styles.code,
259259
},
260260
),
261-
createLinkColumn<AppealListItem, string>(
261+
createLinkColumn<AppealListItem, number>(
262262
'operation',
263263
strings.appealsTableOperation,
264264
(item) => item.name,
@@ -267,13 +267,13 @@ export function Component(props: BaseProps) {
267267
urlParams: { emergencyId: item.event },
268268
}),
269269
),
270-
createStringColumn<AppealListItem, string>(
270+
createStringColumn<AppealListItem, number>(
271271
'dtype',
272272
strings.appealsTableDisastertype,
273273
(item) => item.dtype?.name,
274274
{ sortable: true },
275275
),
276-
createNumberColumn<AppealListItem, string>(
276+
createNumberColumn<AppealListItem, number>(
277277
'amount_requested',
278278
strings.appealsTableRequestedAmount,
279279
(item) => item.amount_requested,
@@ -282,7 +282,7 @@ export function Component(props: BaseProps) {
282282
suffix: ' CHF',
283283
},
284284
),
285-
createProgressColumn<AppealListItem, string>(
285+
createProgressColumn<AppealListItem, number>(
286286
'amount_funded',
287287
strings.appealsTableFundedAmount,
288288
// FIXME: use progress function

app/src/views/CountryProfilePreviousEvents/CountryHistoricalKeyFigures/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ function CountryHistoricalKeyFigures(props: Props) {
7070
<KeyFigure
7171
icon={<FundingIcon />}
7272
className={styles.keyFigure}
73-
value={data.total_amount_requested}
73+
value={data.amount_funded_dref_included}
7474
compactValue
7575
label={strings.keyFiguresFundingRequirements}
7676
/>
7777
<KeyFigure
7878
icon={<FundingCoverageIcon />}
7979
className={styles.keyFigure}
8080
value={getPercentage(
81-
data.total_amount_funded,
82-
data.total_amount_requested,
81+
data.amount_funded_dref_included,
82+
data.amount_requested_dref_included,
8383
)}
8484
suffix="%"
8585
compactValue

app/src/views/CountryProfilePreviousEvents/EmergenciesOverMonth/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ function EmergenciesOverMonth(props: Props) {
4040
url: '/api/v2/country/{id}/disaster-monthly-count/',
4141
pathVariables: { id: countryId },
4242
query: {
43-
start_date: startDate,
44-
end_date: endDate,
43+
start_date_from: startDate,
44+
start_date_to: endDate,
4545
},
4646
});
4747

app/src/views/CountryProfilePreviousEvents/PastEventsChart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ function PastEventsChart(props: Props) {
129129
url: '/api/v2/country/{id}/historical-disaster/',
130130
pathVariables: { id: countryId },
131131
query: isDefined(selectedTimePeriod) ? {
132-
start_date: encodeDate(selectedTimePeriod.startDate),
133-
end_date: encodeDate(selectedTimePeriod.endDate),
132+
start_date_from: encodeDate(selectedTimePeriod.startDate),
133+
start_date_to: encodeDate(selectedTimePeriod.endDate),
134134
} : undefined,
135135
});
136136

0 commit comments

Comments
 (0)