Skip to content

Commit

Permalink
Merge pull request #4835 from GSA/metrics-org-name-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
btylerburton authored Aug 8, 2024
2 parents 3e27cb1 + a993e81 commit 9c98ada
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions metrics/datagov_metrics/ga.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,29 @@ def date_range_last_month():


def get_org_list():
url = "https://catalog.data.gov/api/action/organization_list"
url = 'https://catalog.data.gov/api/action/package_search?q=*:*&facet.field=["organization"]&facet.limit=200&rows=0'
repo = requests.get(url)
data = repo.json()

return data["result"]
return data["result"]["search_facets"]["organization"]["items"]


def setup_organization_reports():
orgs = get_org_list()
org_reports = {}

for org in orgs:
org_name = org["name"]
org_display_name = org["display_name"]
org_dimension_filter = {
"filter": {
"fieldName": "customEvent:DATAGOV_dataset_organization",
"stringFilter": {"matchType": "CONTAINS", "value": org},
"stringFilter": {"matchType": "CONTAINS", "value": org_display_name},
}
}

# report most viewd dataset pages per organization
org_reports[f"{org}__page_requests__last30"] = {
org_reports[f"{org_name}__page_requests__last30"] = {
"dateRanges": date_range_last_month(),
"dimensions": [
{"name": "pagePath"},
Expand All @@ -62,7 +64,7 @@ def setup_organization_reports():
}

# report most downloaded files per organization
org_reports[f"{org}__download_requests__last30"] = {
org_reports[f"{org_name}__download_requests__last30"] = {
"dateRanges": date_range_last_month(),
"dimensions": [
{"name": "linkUrl"},
Expand Down Expand Up @@ -92,7 +94,7 @@ def setup_organization_reports():
}

# report most clicked outboud links per organization
org_reports[f"{org}__link_requests__last30"] = {
org_reports[f"{org_name}__link_requests__last30"] = {
"dateRanges": date_range_last_month(),
"dimensions": [
{"name": "linkUrl"},
Expand Down

0 comments on commit 9c98ada

Please sign in to comment.