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

fix(highcharts): Support global highcharts-cli or env var for path to cli #146

Merged
merged 2 commits into from
Nov 3, 2022
Merged
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
23 changes: 16 additions & 7 deletions server/analytics/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
# AUTHORS and LICENSE files distributed with this source code, or
# at https://www.sourcefabric.org/superdesk/license

from typing import NamedTuple
from typing import NamedTuple, Optional
from os import path
from shutil import which

from superdesk import get_resource_service
from superdesk.utc import utcnow, utc_to_local
from subprocess import check_call, PIPE
from superdesk.default_settings import env

from flask import current_app as app
import pytz
from datetime import datetime, timedelta
Expand Down Expand Up @@ -149,13 +151,20 @@ def get_report_service(report_type):
return None


def get_highcharts_cli_path():
highcharts_cli_path = path.join(
ANALYTICS_PATH,
"node_modules/.bin/highcharts-export-server",
def get_highcharts_cli_path() -> Optional[str]:
highcharts_cli_path = env(
"HIGHCHARTS_CLI_PATH",
path.join(
ANALYTICS_PATH,
"node_modules/.bin/highcharts-export-server",
),
)

return highcharts_cli_path if path.exists(highcharts_cli_path) else None
return (
highcharts_cli_path
if path.exists(highcharts_cli_path)
else which("highcharts-export-server")
)


def get_cv_by_qcode(name, field=None):
Expand Down