Skip to content

Commit

Permalink
Use dataset filtering in events as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Zharktas committed Feb 5, 2024
1 parent 9f8c449 commit e00b269
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ckanext/matomo/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def fetch(dryrun, since, until, dataset):
regex = re.compile('.*id=([a-zA-Z0-9-_]*)&?.*$', re.I)
match = regex.match(stats.get('Events_EventName'))
if match and match[1]:
if dataset and dataset is not match[1]:
if dataset and dataset != match[1]:
continue
package_id_or_name = match[1]
try:
Expand All @@ -163,7 +163,7 @@ def fetch(dryrun, since, until, dataset):
log.exception('Error updating API event statistics for {}: {}'.format(package_id, e))

# Resource page statistics
resource_page_statistics = api.resource_page_statistics(**params)
resource_page_statistics = api.resource_page_statistics(**params, dataset=dataset)
datastore_search_sql_events: Dict[str, Any] = api.events(**params, filter_pattern='datastore_search_sql')

for date_str, date_statistics in resource_page_statistics.items():
Expand Down Expand Up @@ -193,7 +193,11 @@ def fetch(dryrun, since, until, dataset):
if match and match[1]:
resource_id = match[1]
try:
resource_show({'ignore_auth': True}, {'id': resource_id})
resource = resource_show({'ignore_auth': True}, {'id': resource_id})
if dataset:
pkg = package_show({'ignore_auth': True}, {'id': dataset})
if pkg.id != resource['package_id']:
continue
except toolkit.ObjectNotFound:
log.info('Resource "{}" not found, skipping...'.format(resource_id))
continue
Expand Down

0 comments on commit e00b269

Please sign in to comment.