@@ -27,7 +27,7 @@ def calculate(self, conference_id):
2727 filtered_grants = Grant .objects .for_conference (conference )
2828
2929 grants_by_country = filtered_grants .values (
30- "departure_country" , "status "
30+ "departure_country" , "pending_status "
3131 ).annotate (total = Count ("id" ))
3232
3333 (
@@ -110,30 +110,30 @@ def _aggregate_data_by_country(self, grants_by_country, statuses):
110110 if key not in summary :
111111 summary [key ] = {status [0 ]: 0 for status in statuses }
112112
113- summary [key ][data ["status " ]] += data ["total" ]
114- status_totals [data ["status " ]] += data ["total" ]
113+ summary [key ][data ["pending_status " ]] += data ["total" ]
114+ status_totals [data ["pending_status " ]] += data ["total" ]
115115
116116 # Update continent totals
117117 if continent not in totals_per_continent :
118118 totals_per_continent [continent ] = {status [0 ]: 0 for status in statuses }
119- totals_per_continent [continent ][data ["status " ]] += data ["total" ]
119+ totals_per_continent [continent ][data ["pending_status " ]] += data ["total" ]
120120
121121 return summary , status_totals , totals_per_continent
122122
123123 def _aggregate_data_by_country_type (self , filtered_grants , statuses ):
124124 """
125125 Aggregates grant data by country type and status.
126126 """
127- country_type_data = filtered_grants .values ("country_type" , "status" ). annotate (
128- total = Count ( "id" )
129- )
127+ country_type_data = filtered_grants .values (
128+ "country_type" , "pending_status"
129+ ). annotate ( total = Count ( "id" ))
130130 country_type_summary = defaultdict (
131131 lambda : {status [0 ]: 0 for status in statuses }
132132 )
133133
134134 for data in country_type_data :
135135 country_type = data ["country_type" ]
136- status = data ["status " ]
136+ status = data ["pending_status " ]
137137 total = data ["total" ]
138138 country_type_summary [country_type ][status ] += total
139139
@@ -143,13 +143,14 @@ def _aggregate_data_by_gender(self, filtered_grants, statuses):
143143 """
144144 Aggregates grant data by gender and status.
145145 """
146- gender_data = filtered_grants .values ("gender" , "status " ).annotate (
146+ gender_data = filtered_grants .values ("gender" , "pending_status " ).annotate (
147147 total = Count ("id" )
148148 )
149149 gender_summary = defaultdict (lambda : {status [0 ]: 0 for status in statuses })
150+
150151 for data in gender_data :
151152 gender = data ["gender" ] if data ["gender" ] else ""
152- status = data ["status " ]
153+ status = data ["pending_status " ]
153154 total = data ["total" ]
154155 gender_summary [gender ][status ] += total
155156
@@ -159,14 +160,14 @@ def _aggregate_financial_data_by_status(self, filtered_grants, statuses):
159160 """
160161 Aggregates financial data (total amounts) by grant status.
161162 """
162- financial_data = filtered_grants .values ("status " ).annotate (
163+ financial_data = filtered_grants .values ("pending_status " ).annotate (
163164 total_amount_sum = Sum ("total_amount" )
164165 )
165166 financial_summary = {status [0 ]: 0 for status in statuses }
166167 overall_total = 0
167168
168169 for data in financial_data :
169- status = data ["status " ]
170+ status = data ["pending_status " ]
170171 total_amount = data ["total_amount_sum" ] or 0
171172 financial_summary [status ] += total_amount
172173 if status in self .BUDGET_STATUSES :
@@ -178,14 +179,14 @@ def _aggregate_data_by_grant_type(self, filtered_grants, statuses):
178179 """
179180 Aggregates grant data by grant_type and status.
180181 """
181- grant_type_data = filtered_grants .values ("grant_type" , "status" ). annotate (
182- total = Count ( "id" )
183- )
182+ grant_type_data = filtered_grants .values (
183+ "grant_type" , "pending_status"
184+ ). annotate ( total = Count ( "id" ))
184185 grant_type_summary = defaultdict (lambda : {status [0 ]: 0 for status in statuses })
185186
186187 for data in grant_type_data :
187188 grant_types = data ["grant_type" ]
188- status = data ["status " ]
189+ status = data ["pending_status " ]
189190 total = data ["total" ]
190191 for grant_type in grant_types :
191192 grant_type_summary [grant_type ][status ] += total
@@ -213,13 +214,13 @@ def _aggregate_data_by_speaker_status(self, filtered_grants, statuses):
213214
214215 proposed_speaker_data = (
215216 filtered_grants .filter (is_proposed_speaker = True )
216- .values ("status " )
217+ .values ("pending_status " )
217218 .annotate (total = Count ("id" ))
218219 )
219220
220221 confirmed_speaker_data = (
221222 filtered_grants .filter (is_confirmed_speaker = True )
222- .values ("status " )
223+ .values ("pending_status " )
223224 .annotate (total = Count ("id" ))
224225 )
225226
@@ -228,12 +229,12 @@ def _aggregate_data_by_speaker_status(self, filtered_grants, statuses):
228229 )
229230
230231 for data in proposed_speaker_data :
231- status = data ["status " ]
232+ status = data ["pending_status " ]
232233 total = data ["total" ]
233234 speaker_status_summary ["proposed_speaker" ][status ] += total
234235
235236 for data in confirmed_speaker_data :
236- status = data ["status " ]
237+ status = data ["pending_status " ]
237238 total = data ["total" ]
238239 speaker_status_summary ["confirmed_speaker" ][status ] += total
239240
@@ -243,16 +244,16 @@ def _aggregate_data_by_approved_type(self, filtered_grants, statuses):
243244 """
244245 Aggregates grant data by approved type and status.
245246 """
246- approved_type_data = filtered_grants .values ("approved_type" , "status" ). annotate (
247- total = Count ( "id" )
248- )
247+ approved_type_data = filtered_grants .values (
248+ "approved_type" , "pending_status"
249+ ). annotate ( total = Count ( "id" ))
249250 approved_type_summary = defaultdict (
250251 lambda : {status [0 ]: 0 for status in statuses }
251252 )
252253
253254 for data in approved_type_data :
254255 approved_type = data ["approved_type" ]
255- status = data ["status " ]
256+ status = data ["pending_status " ]
256257 total = data ["total" ]
257258 approved_type_summary [approved_type ][status ] += total
258259
@@ -271,11 +272,11 @@ def _aggregate_data_by_requested_needs_summary(self, filtered_grants, statuses):
271272 for field in requested_needs_summary .keys ():
272273 field_data = (
273274 filtered_grants .filter (** {field : True })
274- .values ("status " )
275+ .values ("pending_status " )
275276 .annotate (total = Count ("id" ))
276277 )
277278 for data in field_data :
278- status = data ["status " ]
279+ status = data ["pending_status " ]
279280 total = data ["total" ]
280281 requested_needs_summary [field ][status ] += total
281282
@@ -285,14 +286,14 @@ def _aggregate_data_by_occupation(self, filtered_grants, statuses):
285286 """
286287 Aggregates grant data by occupation and status.
287288 """
288- occupation_data = filtered_grants .values ("occupation" , "status" ). annotate (
289- total = Count ( "id" )
290- )
289+ occupation_data = filtered_grants .values (
290+ "occupation" , "pending_status"
291+ ). annotate ( total = Count ( "id" ))
291292 occupation_summary = defaultdict (lambda : {status [0 ]: 0 for status in statuses })
292293
293294 for data in occupation_data :
294295 occupation = data ["occupation" ]
295- status = data ["status " ]
296+ status = data ["pending_status " ]
296297 total = data ["total" ]
297298 occupation_summary [occupation ][status ] += total
298299
0 commit comments