Skip to content

Commit

Permalink
change naming convention from GA_ to PLAUSIBLE_
Browse files Browse the repository at this point in the history
  • Loading branch information
amdomanska committed Nov 20, 2023
1 parent 6937aa5 commit 7a5cad9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
34 changes: 17 additions & 17 deletions portality/view/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
API_VERSION_NUMBER = '1.0.0'

# Google Analytics category for API events
GA_CATEGORY = app.config.get('PLAUSIBLE_CATEGORY_API', 'API Hit')
GA_ACTIONS = app.config.get('PLAUSIBLE_ACTIONS_API', {})
PLAUSIBLE_CATEGORY = app.config.get('PLAUSIBLE_CATEGORY_API', 'API Hit')
PLAUSIBLE_ACTIONS = app.config.get('PLAUSIBLE_ACTIONS_API', {})

API_UNSUPPORTED_ERROR = "Version 1 is no longer supported."

Expand Down Expand Up @@ -44,7 +44,7 @@ def search_articles(search_query):
@blueprint.route("/articles", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('create_article', 'Create article'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('create_article', 'Create article'))
def create_article():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.create_article', **request.args), code=301)
Expand All @@ -53,7 +53,7 @@ def create_article():

@blueprint.route("/articles/<article_id>", methods=["GET"])
@api_key_optional
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_article', 'Retrieve article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_article', 'Retrieve article'),
record_value_of_which_arg='article_id')
def retrieve_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -64,7 +64,7 @@ def retrieve_article(article_id):
@blueprint.route("/articles/<article_id>", methods=["PUT"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('update_article', 'Update article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('update_article', 'Update article'),
record_value_of_which_arg='article_id')
def update_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -75,7 +75,7 @@ def update_article(article_id):
@blueprint.route("/articles/<article_id>", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('delete_article', 'Delete article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('delete_article', 'Delete article'),
record_value_of_which_arg='article_id')
def delete_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -86,7 +86,7 @@ def delete_article(article_id):
@blueprint.route("/bulk/articles", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_article_create', 'Bulk article create'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_article_create', 'Bulk article create'))
def bulk_article_create():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301)
Expand All @@ -96,7 +96,7 @@ def bulk_article_create():
@blueprint.route("/bulk/articles", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_article_delete', 'Bulk article delete'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_article_delete', 'Bulk article delete'))
def bulk_article_delete():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_delete', **request.args), code=301)
Expand All @@ -108,7 +108,7 @@ def bulk_article_delete():

@blueprint.route('/journals/<journal_id>', methods=['GET'])
@api_key_optional
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_journal', 'Retrieve journal'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_journal', 'Retrieve journal'),
record_value_of_which_arg='journal_id')
def retrieve_journal(journal_id):
raise Api400Error(API_UNSUPPORTED_ERROR)
Expand All @@ -117,30 +117,30 @@ def retrieve_journal(journal_id):
@blueprint.route("/bulk/applications", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_application_create', 'Bulk application create'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_application_create', 'Bulk application create'))
def bulk_application_create():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/bulk/applications", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_application_delete', 'Bulk application delete'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_application_delete', 'Bulk application delete'))
def bulk_application_delete():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/applications", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('create_application', 'Create application'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('create_application', 'Create application'))
def create_application():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/applications/<application_id>", methods=["GET"])
@api_key_required
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_application', 'Retrieve application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_application', 'Retrieve application'),
record_value_of_which_arg='application_id')
def retrieve_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)
Expand All @@ -149,7 +149,7 @@ def retrieve_application(application_id):
@blueprint.route("/applications/<application_id>", methods=["PUT"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('update_application', 'Update application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('update_application', 'Update application'),
record_value_of_which_arg='application_id')
def update_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)
Expand All @@ -158,22 +158,22 @@ def update_application(application_id):
@blueprint.route("/applications/<application_id>", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('delete_application', 'Delete application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('delete_application', 'Delete application'),
record_value_of_which_arg='application_id')
def delete_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/search/applications/<path:search_query>")
@api_key_required
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('search_applications', 'Search applications'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('search_applications', 'Search applications'),
record_value_of_which_arg='search_query')
def search_applications(search_query):
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route('/search/journals/<path:search_query>')
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('search_journals', 'Search journals'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('search_journals', 'Search journals'),
record_value_of_which_arg='search_query')
def search_journals(search_query):
raise Api400Error(API_UNSUPPORTED_ERROR)
34 changes: 17 additions & 17 deletions portality/view/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
API_VERSION_NUMBER = '2.0.0'

# Google Analytics category for API events
GA_CATEGORY = app.config.get('PLAUSIBLE_CATEGORY_API', 'API Hit')
GA_ACTIONS = app.config.get('PLAUSIBLE_ACTIONS_API', {})
PLAUSIBLE_CATEGORY = app.config.get('PLAUSIBLE_CATEGORY_API', 'API Hit')
PLAUSIBLE_ACTIONS = app.config.get('PLAUSIBLE_ACTIONS_API', {})

API_UNSUPPORTED_ERROR = "Version 2 is no longer supported."

Expand Down Expand Up @@ -44,7 +44,7 @@ def search_articles(search_query):
@blueprint.route("/articles", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('create_article', 'Create article'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('create_article', 'Create article'))
def create_article():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.create_article', **request.args), code=301)
Expand All @@ -53,7 +53,7 @@ def create_article():

@blueprint.route("/articles/<article_id>", methods=["GET"])
@api_key_optional
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_article', 'Retrieve article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_article', 'Retrieve article'),
record_value_of_which_arg='article_id')
def retrieve_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -64,7 +64,7 @@ def retrieve_article(article_id):
@blueprint.route("/articles/<article_id>", methods=["PUT"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('update_article', 'Update article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('update_article', 'Update article'),
record_value_of_which_arg='article_id')
def update_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -75,7 +75,7 @@ def update_article(article_id):
@blueprint.route("/articles/<article_id>", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('delete_article', 'Delete article'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('delete_article', 'Delete article'),
record_value_of_which_arg='article_id')
def delete_article(article_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -86,7 +86,7 @@ def delete_article(article_id):
@blueprint.route("/bulk/articles", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_article_create', 'Bulk article create'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_article_create', 'Bulk article create'))
def bulk_article_create():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_create', **request.args), code=301)
Expand All @@ -96,7 +96,7 @@ def bulk_article_create():
@blueprint.route("/bulk/articles", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_article_delete', 'Bulk article delete'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_article_delete', 'Bulk article delete'))
def bulk_article_delete():
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
# return redirect(url_for('api_v3.bulk_article_delete', **request.args), code=301)
Expand All @@ -108,7 +108,7 @@ def bulk_article_delete():

@blueprint.route('/journals/<journal_id>', methods=['GET'])
@api_key_optional
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_journal', 'Retrieve journal'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_journal', 'Retrieve journal'),
record_value_of_which_arg='journal_id')
def retrieve_journal(journal_id):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -119,30 +119,30 @@ def retrieve_journal(journal_id):
@blueprint.route("/bulk/applications", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_application_create', 'Bulk application create'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_application_create', 'Bulk application create'))
def bulk_application_create():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/bulk/applications", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('bulk_application_delete', 'Bulk application delete'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('bulk_application_delete', 'Bulk application delete'))
def bulk_application_delete():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/applications", methods=["POST"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('create_application', 'Create application'))
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('create_application', 'Create application'))
def create_application():
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/applications/<application_id>", methods=["GET"])
@api_key_required
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('retrieve_application', 'Retrieve application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('retrieve_application', 'Retrieve application'),
record_value_of_which_arg='application_id')
def retrieve_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)
Expand All @@ -151,7 +151,7 @@ def retrieve_application(application_id):
@blueprint.route("/applications/<application_id>", methods=["PUT"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('update_application', 'Update application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('update_application', 'Update application'),
record_value_of_which_arg='application_id')
def update_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)
Expand All @@ -160,15 +160,15 @@ def update_application(application_id):
@blueprint.route("/applications/<application_id>", methods=["DELETE"])
@api_key_required
@write_required(api=True)
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('delete_application', 'Delete application'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('delete_application', 'Delete application'),
record_value_of_which_arg='application_id')
def delete_application(application_id):
raise Api400Error(API_UNSUPPORTED_ERROR)


@blueprint.route("/search/applications/<path:search_query>")
@api_key_required
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('search_applications', 'Search applications'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('search_applications', 'Search applications'),
record_value_of_which_arg='search_query')
def search_applications(search_query):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand All @@ -177,7 +177,7 @@ def search_applications(search_query):


@blueprint.route('/search/journals/<path:search_query>')
@plausible.pa_event(GA_CATEGORY, action=GA_ACTIONS.get('search_journals', 'Search journals'),
@plausible.pa_event(PLAUSIBLE_CATEGORY, action=PLAUSIBLE_ACTIONS.get('search_journals', 'Search journals'),
record_value_of_which_arg='search_query')
def search_journals(search_query):
# Redirects are disabled https://github.com/DOAJ/doajPM/issues/2664
Expand Down
Loading

0 comments on commit 7a5cad9

Please sign in to comment.