Skip to content

Commit

Permalink
Add OKR output (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans authored Nov 18, 2024
1 parent 7166b29 commit cc67e69
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
17 changes: 14 additions & 3 deletions get_org_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def main(downloads, output_dir, **ignore):
organisation["delinquent datasets"] += 1
if datasetstats.in_explorer_or_grid == "Y":
organisation["in explorer or grid"] = "Yes"
if datasetstats.updated_by_cod_script == "Y":
if datasetstats.updated_by_cod_script == "Y" and is_public_not_requestable_archived:
organisation["updated by cod script"] += 1
total_updated_by_cod += 1
if datasetstats.created > organisation["latest created dataset date"]:
Expand All @@ -188,7 +188,7 @@ def main(downloads, output_dir, **ignore):
"latest scripted update date"]:
organisation[
"latest scripted update date"] = datasetstats.last_modified
if datasetstats.updated_by_noncod_script == "Y":
if datasetstats.updated_by_noncod_script == "Y" and is_public_not_requestable_archived:
organisation["updated by script"] += 1
total_updated_by_script += 1
if datasetstats.outdated_lastmodified == "Y":
Expand Down Expand Up @@ -357,11 +357,22 @@ def get_number_percentage(organisation, key):
message.append("\n")
logger.warning("".join(message))

logger.info(f"Total public datasets = {total_public}")
logger.info(f"Total public datasets (excluding requestable, archived) = {total_public}")
logger.info(f"Total public updated by cod script = {total_updated_by_cod}")
logger.info(
f"Total public updated by all other scripts = {total_updated_by_script}"
)
quarterly_okr = get_fraction_str(
total_updated_by_script * 100,
total_public,
format="%.0f",
)
logger.info(f"Quarterly OKR = {quarterly_okr}")
filepath = join(output_dir, "total_stats.csv")
logger.info(f"Writing totals to {filepath}")
headers = ["Public - request & archive", "Updated by COD", "Updated by Script", "Quarterly OKR"]
rows = [[total_public, total_updated_by_cod, total_updated_by_script, quarterly_okr]]
write_list_to_csv(filepath, rows, headers, encoding="utf-8")
return total_public, total_updated_by_cod, total_updated_by_script


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hdx-python-api==6.3.1
hdx-python-api==6.3.5
mixpanel-utils
4 changes: 2 additions & 2 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==8.3.1
pytest-cov==5.0.0
pytest==8.3.3
pytest-cov==6.0.0
-r requirements.txt
2 changes: 2 additions & 0 deletions tests/fixtures/total_stats.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Public - request & archive,Updated by COD,Updated by Script,Quarterly OKR
20823,583,16594,80
2 changes: 2 additions & 0 deletions tests/test_get_org_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ def test_get_org_stats(self, configuration, fixtures, mock_downloads):
assert total_updated_by_script == 16594
filename = "org_stats.csv"
assert_files_same(join(fixtures, filename), join(folder, filename))
filename = "total_stats.csv"
assert_files_same(join(fixtures, filename), join(folder, filename))

0 comments on commit cc67e69

Please sign in to comment.