Skip to content

Commit

Permalink
Remove broken exclusion of activities from traceable denominator
Browse files Browse the repository at this point in the history
codeforIATI#21

This was meant to exclude activities that were only referenced by
themselves from the denominator, but the calculation was at the
publisher level, where we don't know if other publishers will reference
them yet.
  • Loading branch information
Bjwebb committed Jun 22, 2024
1 parent 2ce3876 commit 8bef616
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions stats/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1840,15 +1840,6 @@ def provider_activity_id_without_own(self):
out = {k: v for k, v in self.aggregated['provider_activity_id'].items() if k not in self.aggregated['iati_identifiers']}
return out

@returns_numberdict
def provider_activity_id_own_only(self):
out = defaultdict(int)
for activity_id, provider_activity_ids in self.aggregated['provider_activity_id_by_activity_id'].items():
if all(x in self.aggregated['iati_identifiers'] for x in provider_activity_ids):
for provider_activity_id, count in provider_activity_ids.items():
out[provider_activity_id] += count
return out

@returns_numberdictdict
def sum_commitments_and_disbursements_by_activity_id_by_publisher_id_usd(self):
# These 2 by_publisher_id functions produce similar data to the invert
Expand Down Expand Up @@ -1915,8 +1906,7 @@ def traceable_sum_commitments_and_disbursements_by_publisher_id_denominator(self
out = defaultdict(Decimal)
for publisher_id, d in self.aggregated['sum_commitments_and_disbursements_by_activity_id_by_publisher_id_usd'].items():
for k, v in d.items():
if k not in self.aggregated['provider_activity_id_own_only']:
out[publisher_id] += v
out[publisher_id] += v
return out

@returns_numberdict
Expand All @@ -1933,6 +1923,5 @@ def traceable_activities_by_publisher_id_denominator(self):
out = defaultdict(int)
for publisher_id, iati_identifiers_counts in self.aggregated['iati_identifiers_by_publisher_id'].items():
for iati_identifier, count in iati_identifiers_counts.items():
if iati_identifier not in self.aggregated['provider_activity_id_own_only']:
out[publisher_id] += count
out[publisher_id] += count
return out

0 comments on commit 8bef616

Please sign in to comment.