Skip to content

Commit

Permalink
Merge pull request #80 from codeforIATI/org-ids
Browse files Browse the repository at this point in the history
Add org ids stats tables, including to publisher page
  • Loading branch information
Bjwebb authored Dec 9, 2022
2 parents 4d6e620 + 1967c84 commit a636419
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 2 deletions.
3 changes: 2 additions & 1 deletion data.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,6 @@ def make_slugs(keys):
if major_version in current_stats['inverted_publisher']['codelist_values_by_major_version']
else make_slugs([])
) for major_version in MAJOR_VERSIONS},
'element': make_slugs(current_stats['inverted_publisher']['elements'].keys())
'element': make_slugs(current_stats['inverted_publisher']['elements'].keys()),
'org_type': make_slugs(['accountable_org', 'extending_org', 'funding_org', 'implementing_org', 'provider_org', 'receiver_org']),
}
11 changes: 11 additions & 0 deletions make_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def get_codelist_values(codelist_values_for_element):
'booleans',
'dates',
'traceability',
'org_ids',
'faq',
]

Expand Down Expand Up @@ -300,6 +301,14 @@ def element(slug):
page='elements')


@app.route('/org_type/<slug>.html')
def org_type(slug):
assert slug in slugs['org_type']['by_slug']
return render_template('org_type.html',
slug=slug,
page='org_ids')


@app.route('/registration_agencies.html')
def registration_agencies():
registration_agencies = defaultdict(int)
Expand Down Expand Up @@ -366,6 +375,8 @@ def url_generator():
'slug': slug,
'major_version': major_version
}
for slug in slugs['org_type']['by_slug']:
yield 'org_type', {'slug': slug}
for license in set(licenses.licenses):
yield 'licenses_individual_license', {'license': license}

Expand Down
12 changes: 12 additions & 0 deletions templates/org_id_table_cells.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<td>{{ '{:,}'.format(transaction_stats.total_orgs or 0) }}</th>
<td>{{ '{:,}'.format(transaction_stats.total_refs or 0) }}</th>
<td>{{ '{:,}'.format(transaction_stats.total_full_refs or 0) }}</th>
{% set self_refs = (transaction_stats.total_full_refs or 0) - (transaction_stats.total_notself_refs or 0) %}
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;">{{ '{:,}'.format(self_refs) }}</th>
{% set total_org_elements_excluding_self_refs = (transaction_stats.total_orgs or 0) - self_refs %}
<td>{{ '{:,}'.format(total_org_elements_excluding_self_refs) }}</th>
{% set total_refs_excluding_self_refs = (transaction_stats.total_refs or 0) - self_refs %}
<td>{{ '{:,}'.format(total_refs_excluding_self_refs) }}</th>
<td>{{ '{:,}'.format(transaction_stats.total_notself_refs or 0) }}</th>
<td>{{ '{:,}'.format(transaction_stats.total_valid_refs or 0) }}</th>
<td>{{ (((transaction_stats.total_valid_refs or 0) / total_org_elements_excluding_self_refs * 100) if total_org_elements_excluding_self_refs else 0) | round_nicely }}</th>
16 changes: 16 additions & 0 deletions templates/org_id_table_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" colspan="3">Total</th>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2">Self Refs</th>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" colspan="5">Excluding Self Refs</th>
{% if extra_column %}
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2"></th>
{% endif %}
</tr>
<tr>
<th>Org Elements</th>
<th>Refs</th>
<th>Non-Empty Refs</th>
<th>Org Elements</th>
<th>Refs</th>
<th>Non-Empty Refs</th>
<th>Valid Refs</th>
<th>Percentage of Org Elements with Valid Refs</th>
30 changes: 30 additions & 0 deletions templates/org_ids.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'base.html' %}
{% block content %}
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default">
<div class="panel-body">
{% include '_partials/tablesorter_instructions.html' %}
</div>
<table class="table table-striped">
<thead>
<tr>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2">Org Type</th>
{% include 'org_id_table_header.html' %}
</tr>
</thead>
<tbody>
{% for slug in slugs.org_type.by_slug %}
{% set transaction_stats = current_stats.aggregated[slug + '_transaction_stats'] %}
<tr>
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;"><a href="{{ url_for('org_type', slug=slug) }}" >{{ slug.replace('_org', '') | capitalize }}</a></td>
{% include 'org_id_table_cells.html' %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

{% endblock %}
41 changes: 41 additions & 0 deletions templates/org_type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends 'base.html' %}

{% block title %}
Organisation Identifiers: {{ slug.replace('_org', '') | capitalize }} Orgs
{% endblock %}

{% block page_header %}
<h1>Organisation Identifiers: {{ slug.replace('_org', '') | capitalize }} Orgs</h1>
{% endblock %}

{% block content %}
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default">
<div class="panel-body">
{% include '_partials/tablesorter_instructions.html' %}
</div>
<table class="table table-striped">
<thead>
<tr>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2">Publisher Name</th>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2">Publisher Registry Id</th>
{% include 'org_id_table_header.html' %}
</tr>
</thead>
<tbody>
{% for publisher_title, publisher in publishers_ordered_by_title %}
{% set publisher_stats = get_publisher_stats(publisher) %}
{% set transaction_stats = publisher_stats[slug + '_transaction_stats'] %}
<tr>
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;"><a href="{{ url_for('publisher', publisher=publisher) }}#p_org_ids">{{ publisher_name[publisher] }}</a></td>
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;"><a href="{{ url_for('publisher', publisher=publisher) }}#p_org_ids">{{ publisher }}</a></td>
{% include 'org_id_table_cells.html' %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
27 changes: 27 additions & 0 deletions templates/publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h1>Publisher: {{ publisher_name[publisher] }}</h1>
<li><a href="#p_files">Files</a>
<li><a href="#p_codelists">Codelist values</a>
<li><a href="#p_elements">Elements and Attributes published</a>
<li><a href="#p_org_ids">Organisation Identifiers</a>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -436,6 +437,32 @@ <h3 class="panel-title">Elements and Attributes Published</h3>
</table>
</div>

<div class="panel panel-default" id="p_org_ids">
<table class="table table-striped">
<div class="panel-heading">
<h3 class="panel-title">Organisation Identifiers</h3>
</div>
<table class="table table-striped">
<thead>
<tr>
<th style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;" rowspan="2">Org Type</th>
{% set extra_column = true %}
{% include 'org_id_table_header.html' %}
</tr>
</thead>
<tbody>
{% for slug in slugs.org_type.by_slug %}
{% set transaction_stats = publisher_stats[slug + '_transaction_stats'] %}
<tr>
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;"><a href="{{ url_for('org_type', slug=slug) }}" >{{ slug.replace('_org', '') | capitalize }}</a></td>
{% include 'org_id_table_cells.html' %}
<td style="border-left: 1px solid #ddd; border-right: 1px solid #ddd;"><a href="{{ stats_url }}/current/aggregated-publisher/{{ publisher }}/{{ slug }}_transaction_stats.json">(J)</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>

{% endblock %}

{% block extrafooter %}
Expand Down
4 changes: 3 additions & 1 deletion text.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'booleans': 'Booleans',
'dates': 'Dates',
'traceability': 'Traceability',
'org_ids': 'Organisation Identifiers',
'publishing_stats': 'Publishing Statistics',
'coverage': 'Coverage',
'timeliness': 'Timeliness',
Expand Down Expand Up @@ -64,6 +65,7 @@
'booleans': 'How are booleans used in IATI data?',
'dates': 'What date ranges do publishers publish data for?',
'traceability': 'How much of a publisher’s spending is traceable to other publishers’ activities?',
'org_ids': 'Are organisation identifiers being used correctly?',
}
page_sub_leads = {
'publishers': 'Publishers represent organisation accounts in the IATI Registry.',
Expand Down Expand Up @@ -98,6 +100,6 @@
navigation = {
'headlines': ['publishers', 'files', 'activities'],
'data_quality': ['download', 'xml', 'validation', 'versions', 'licenses', 'organisation', 'identifiers', 'reporting_orgs'],
'exploring_data': ['elements', 'codelists', 'booleans', 'dates', 'traceability'],
'exploring_data': ['elements', 'codelists', 'booleans', 'dates', 'traceability', 'org_ids'],
'publishing_stats': ['timeliness', 'forwardlooking', 'comprehensiveness', 'summary_stats', 'humanitarian']
}

0 comments on commit a636419

Please sign in to comment.