Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename extension #9

Merged
merged 14 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ jobs:
sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini

ckan -c test.ini db init
ckan -c test.ini db upgrade -p tracking
ckan -c test.ini db upgrade -p api_tracking

- name: Run tests
run: pytest --ckan-ini=test.ini -v --disable-warnings ckanext/tracking
run: pytest --ckan-ini=test.ini -v --disable-warnings ckanext/api_tracking

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include README.md
include LICENSE
include requirements.txt
recursive-include ckanext/tracking *.html *.json *.js *.less *.css *.mo *.yml
recursive-include ckanext/tracking/migration *.ini *.py *.mako
recursive-include ckanext/api_tracking *.html *.json *.js *.less *.css *.mo *.yml
recursive-include ckanext/api_tracking/migration *.ini *.py *.mako
1 change: 1 addition & 0 deletions ckanext/api_tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__VERSION__ = '0.4.0'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ckan.plugins import toolkit
from ckanext.tracking.queries.api import (
from ckanext.api_tracking.queries.api import (
get_all_token_usage,
get_most_accessed_dataset_with_token,
get_most_accessed_token,
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions ckanext/api_tracking/blueprints/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# flake8: noqa: F401

from ckanext.api_tracking.blueprints.csv import tracking_csv_blueprint
from ckanext.api_tracking.blueprints.dashboard import tracking_dashboard_blueprint
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ckan.common import current_user
from ckan.plugins import toolkit

from ckanext.tracking.queries.data import (
from ckanext.api_tracking.queries.data import (
all_token_usage_data,
most_accessed_token_data,
most_accessed_dataset_with_token_data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from flask import Blueprint
from ckan.plugins.toolkit import render, h
from ckanext.stats import stats as stats_lib
from ckanext.tracking.dashboard.stats import get_dataset_views, get_unique_dataset_views, get_resource_downloads
from ckanext.tracking.dashboard.stats_api import get_api_token_usage_aggregated, get_latest_api_token_usage
from ckanext.tracking.decorators import require_sysadmin_user
from ckanext.api_tracking.dashboard.stats import get_dataset_views, get_unique_dataset_views, get_resource_downloads
from ckanext.api_tracking.dashboard.stats_api import get_api_token_usage_aggregated, get_latest_api_token_usage
from ckanext.api_tracking.decorators import require_sysadmin_user


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ If a user views a dataset multiple times in a period, it will only be counted on

Based on the tracking_raw table because the tracking_summary table does not allow to count unique views in a period.

This query is used in ckanext/tracking/dashboard/stats.py module to collect views statistics.
This query is used in ckanext/api_tracking/dashboard/stats.py module to collect views statistics.
*/

SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from datetime import datetime, timedelta
from ckan import model
from ckanext.tracking.dashboard import query_results
from ckanext.api_tracking.dashboard import query_results


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import logging
from ckan.plugins import toolkit
from ckanext.tracking.queries.data import (
from ckanext.api_tracking.queries.data import (
all_token_usage_data,
most_accessed_token_data,
most_accessed_dataset_with_token_data,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from ckan import plugins
from ckan.plugins.interfaces import Interface
from ckanext.tracking.models import TrackingUsage, CKANURL
from ckanext.api_tracking.models import TrackingUsage, CKANURL


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ckan.model import ApiToken
from ckan.types import CKANApp

from ckanext.tracking.interfaces import IUsage
from ckanext.api_tracking.interfaces import IUsage


log = logging.getLogger(__name__)
Expand Down
4 changes: 4 additions & 0 deletions ckanext/api_tracking/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# flake8: noqa: F401

from ckanext.api_tracking.models.tracking import TrackingUsage
from ckanext.api_tracking.models.url import CKANURL
File renamed without changes.
12 changes: 6 additions & 6 deletions ckanext/tracking/plugin.py → ckanext/api_tracking/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from ckan import plugins
from ckan.plugins import toolkit

from ckanext.tracking import blueprints
from ckanext.tracking.interfaces import IUsage
from ckanext.tracking.middleware import TrackingUsageMiddleware
from ckanext.tracking.auth import csv as auth_csv
from ckanext.tracking.auth import queries as auth_queries
from ckanext.tracking.actions import queries as action_queries
from ckanext.api_tracking import blueprints
from ckanext.api_tracking.interfaces import IUsage
from ckanext.api_tracking.middleware import TrackingUsageMiddleware
from ckanext.api_tracking.auth import csv as auth_csv
from ckanext.api_tracking.auth import queries as auth_queries
from ckanext.api_tracking.actions import queries as action_queries


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ckan import model
from sqlalchemy import func, desc
from ckanext.tracking.models import TrackingUsage
from ckanext.api_tracking.models import TrackingUsage


def get_most_accessed_dataset_with_token(limit=10):
Expand Down
5 changes: 5 additions & 0 deletions ckanext/api_tracking/queries/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# flake8: noqa: F401

from ckanext.api_tracking.queries.data.all import all_token_usage_data
from ckanext.api_tracking.queries.data.dataset import most_accessed_dataset_with_token_data
from ckanext.api_tracking.queries.data.token import most_accessed_token_data
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ckan import model
from ckan.plugins import toolkit

from ckanext.tracking.queries.api import get_all_token_usage
from ckanext.api_tracking.queries.api import get_all_token_usage


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ckan import model
from ckan.plugins import toolkit

from ckanext.tracking.queries.api import get_most_accessed_dataset_with_token
from ckanext.api_tracking.queries.api import get_most_accessed_dataset_with_token


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ckan import model
from ckan.plugins import toolkit

from ckanext.tracking.queries.api import get_most_accessed_token
from ckanext.api_tracking.queries.api import get_most_accessed_token


log = logging.getLogger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ckan import model
from ckan.plugins import toolkit
from ckantoolkit.tests import factories
from ckanext.tracking.models import TrackingUsage
from ckanext.api_tracking.models import TrackingUsage


class TrackingUsageF(factory.Factory):
Expand Down
7 changes: 7 additions & 0 deletions ckanext/api_tracking/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest


@pytest.fixture
def api_tracking_migrate(migrate_db_for):
""" Apply the tracking migrations """
migrate_db_for('api_tracking')
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from ckan.lib.helpers import url_for
from ckan.tests import factories

from ckanext.tracking.tests import factories as tf
from ckanext.api_tracking.tests import factories as tf


@pytest.fixture
Expand All @@ -24,7 +24,7 @@ def base_data():
return obj


@pytest.mark.usefixtures('clean_db', 'tracking_migrate')
@pytest.mark.usefixtures('clean_db', 'api_tracking_migrate')
class TestTrackingCSVView:
""" Test basic tracking from requests """
def test_dataset_with_token_csv_no_user(self, app):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup_data():
return obj


@pytest.mark.usefixtures('clean_db', 'clean_index', 'tracking_migrate')
@pytest.mark.usefixtures('clean_db', 'clean_index', 'api_tracking_migrate')
class TestDashboardTab:
""" Test who can see the dashboard tab """
def test_member_admin_cant_see(self, app, setup_data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setup_data():
return obj


@pytest.mark.usefixtures('clean_db', 'clean_index', 'tracking_migrate')
@pytest.mark.usefixtures('clean_db', 'clean_index', 'api_tracking_migrate')
class TestDashboardTabs:
""" Test dashboard tabks """
def _test_dashboard_tab(self, app, user, fn, status):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_some_action():
from ckan import plugins


@pytest.mark.ckan_config("ckan.plugins", "tracking")
@pytest.mark.ckan_config("ckan.plugins", "api_tracking")
@pytest.mark.usefixtures("with_plugins")
def test_plugin():
assert plugins.plugin_loaded("tracking")
assert plugins.plugin_loaded("api_tracking")
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ckan.lib.helpers import url_for
from ckan.tests import factories

from ckanext.tracking.models.tracking import TrackingUsage
from ckanext.api_tracking.models.tracking import TrackingUsage


class TestTrackingUsageBasic:
Expand Down
1 change: 0 additions & 1 deletion ckanext/tracking/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions ckanext/tracking/blueprints/__init__.py

This file was deleted.

4 changes: 0 additions & 4 deletions ckanext/tracking/models/__init__.py

This file was deleted.

5 changes: 0 additions & 5 deletions ckanext/tracking/queries/data/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions ckanext/tracking/tests/fixtures.py

This file was deleted.

2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest_plugins = [
u'ckanext.tracking.tests.fixtures',
u'ckanext.api_tracking.tests.fixtures',
]
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ckanext-tracking"
name = "ckanext-api-tracking"
# see tool.setuptools.dynamic in this file
dynamic = ["version"]
description = "CKAN extension to track users activity"
Expand All @@ -29,8 +29,8 @@ classifiers = [
]

[project.urls]
"Homepage" = "https://github.com/NorwegianRefugeeCouncil/ckanext-tracking"
"Issues" = "https://github.com/NorwegianRefugeeCouncil/ckanext-tracking/issues"
"Homepage" = "https://github.com/NorwegianRefugeeCouncil/ckanext-api-tracking"
"Issues" = "https://github.com/NorwegianRefugeeCouncil/ckanext-api-tracking/issues"

# [project.dependencies]
# Dependencies should be listed in requirements.txt as per CKAN extension best practices
Expand All @@ -54,7 +54,7 @@ namespaces = true
include = ["*"]

[tool.setuptools.dynamic]
version = {attr = "ckanext.tracking.__VERSION__"}
version = {attr = "ckanext.api_tracking.__VERSION__"}

[tool.setuptools.data-files]
# Data files can be listed here
Expand All @@ -67,7 +67,7 @@ version = {attr = "ckanext.tracking.__VERSION__"}
# your_command = "your_module:main"

[project.entry-points."ckan.plugins"]
tracking = "ckanext.tracking.plugin:TrackingPlugin"
api_tracking = "ckanext.api_tracking.plugin:TrackingPlugin"

[project.entry-points."babel.extractors"]
ckan = "ckan.lib.extract:extract_ckan"
Expand Down
7 changes: 1 addition & 6 deletions test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ smtp_server = localhost
error_email_from = ckan@localhost

[app:main]
ckan.datastore.read_url = postgresql://datastore_read:pass@postgresql_nrc/datastore_test
ckan.datastore.write_url = postgresql://datastore_write:pass@postgresql_nrc/datastore_test
solr_url = http://solr_nrc:8983/solr/ckan
ckan.redis.url = redis://redis_nrc:6379/0
sqlalchemy.url = postgresql://ckan_default:pass@postgresql_nrc/ckan_test
use = config:../../ckan/test-core.ini

# Insert any custom config settings to be used when running your extension's
# tests here. These will override the one defined in CKAN core's test-core.ini
ckan.plugins = tracking
ckan.plugins = api_tracking


# Logging configuration
Expand Down