Skip to content

Commit

Permalink
Add uptodate using end date and fresh using last modified to output (#7)
Browse files Browse the repository at this point in the history
* Up to dateness and the older freshness stat

* Add schedule to ensure quarterly runs
  • Loading branch information
mcarans authored Dec 30, 2024
1 parent 1becd8c commit b6daa9f
Show file tree
Hide file tree
Showing 14 changed files with 27,676 additions and 27,517 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/run-python-script-datasetsinfo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: run_datasetsinfo

on:
workflow_dispatch: # add run button in github
schedule:
- cron: "10 0 1 */3 *"

jobs:
run:

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/run-python-script-orgstats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ name: run_orgstats

on:
workflow_dispatch: # add run button in github
schedule:
- cron: "0 0 1 */3 *"

jobs:
run:

Expand Down
19 changes: 11 additions & 8 deletions common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,30 @@ def get_requests_mappings(downloads):
organisation_name_to_requests = {}
for request in downloads.get_requests():
dict_of_lists_add(dataset_id_to_requests, request["package_id"], request)
dict_of_lists_add(organisation_name_to_requests, request["pkg_organization_name"], request)
dict_of_lists_add(
organisation_name_to_requests, request["pkg_organization_name"], request
)
return dataset_id_to_requests, organisation_name_to_requests


def get_freshness_by_frequency(downloads, url):
yaml = downloads.get_aging(url)
freshness_by_frequency = {}
for key, value in yaml["aging"].items():
def get_aging(aging_config):
aging = {}
for key, value in aging_config.items():
update_frequency = int(key)
freshness_frequency = {}
for status in value:
nodays = value[status]
freshness_frequency[status] = timedelta(days=nodays)
freshness_by_frequency[update_frequency] = freshness_frequency
return freshness_by_frequency
aging[update_frequency] = freshness_frequency
return aging


def get_previous_quarter(date):
if date.month < 4:
start_date = datetime(date.year - 1, 10, 1, 0, 0, tzinfo=timezone.utc)
end_date = datetime(date.year - 1, 12, 31, 23, 59, 59, 999999, tzinfo=timezone.utc)
end_date = datetime(
date.year - 1, 12, 31, 23, 59, 59, 999999, tzinfo=timezone.utc
)
elif date.month < 7:
start_date = datetime(date.year, 1, 1, 0, 0, tzinfo=timezone.utc)
end_date = datetime(date.year, 3, 31, 23, 59, 59, 999999, tzinfo=timezone.utc)
Expand Down
1 change: 1 addition & 0 deletions common/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# encoding: utf-8

"""File compare utilities."""

import difflib
from os import linesep
from typing import List
Expand Down
Loading

0 comments on commit b6daa9f

Please sign in to comment.