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

[SDESK-5133] Use appConfig instead of config/deployConfig #121

Merged
merged 4 commits into from
Mar 26, 2020
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
22 changes: 22 additions & 0 deletions .travis-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "2.4"
services:
redis:
image: redis:alpine
ports:
- "6379:6379"

mongo:
image: mongo:3.6
ports:
- "27017:27017"
tmpfs:
- /data/db

elastic:
image: elasticsearch:2.4-alpine
ports:
- "9200:9200"
environment:
- discovery.type=single-node
tmpfs:
- /usr/share/elasticsearch/data
58 changes: 27 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
language: python

python: 3.5
python: 3.6

dist: xenial
sudo: required
dist: bionic

env:
global:
- TRAVIS_NODE_VERSION="6"
- TRAVIS_NODE_VERSION="10"

services:
- mongodb
- redis-server
- docker

addons:
apt:
sources:
- mongodb-3.0-precise
- elasticsearch-2.x
packages:
- mongodb-org-server
- elasticsearch
chrome: stable

cache:
- pip
- npm

before_install:
- node --version
- sudo apt-get purge elasticsearch
- sudo apt-get install -t stable elasticsearch
- sudo service elasticsearch restart

install:
- npm install
- cd server && pip install -r requirements.txt && cd ..
- chmod a+x server/scripts/install-highcharts-export-server.sh
- pip install -e .

script:
- cd server && python3 -u -m analytics.reports.highcharts_server &
- make testpy
- make testjs

after_success:
- coveralls
- |
if [ "$CLIENT" == "true" ]; then
nvm install 10
npm install
fi
- |
if [ "$SERVER" == "true" ]; then
docker-compose -f .travis-docker-compose.yml up -d
cd server && pip install -r requirements.txt && cd ..
chmod a+x server/scripts/install-highcharts-export-server.sh
pip install -e .
cd server && python3 -u -m analytics.reports.highcharts_server &
fi

jobs:
include:
- name: "server"
env: SERVER=true
script: make testpy
- name: "client"
env: CLIENT=true
script: make testjs
15 changes: 6 additions & 9 deletions client/charts/services/ChartConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {appConfig} from 'superdesk-core/scripts/appConfig';

import {formatDate, getTranslatedOperations} from '../../utils';
import {SDChart} from '../SDChart';
import {DATE_FILTERS} from '../../search/common';
Expand All @@ -8,7 +10,6 @@ ChartConfig.$inject = [
'gettext',
'gettextCatalog',
'moment',
'config',
'$q',
'userList',
'desks',
Expand All @@ -26,7 +27,6 @@ ChartConfig.$inject = [
* @param gettext
* @param gettextCatalog
* @param moment
* @param config
* @param $q
* @param userList
* @param desks
Expand All @@ -41,7 +41,6 @@ export function ChartConfig(
gettext,
gettextCatalog,
moment,
config,
$q,
userList,
desks,
Expand Down Expand Up @@ -703,16 +702,14 @@ export function ChartConfig(
const start = _.get(params, 'dates.start');
const end = _.get(params, 'dates.end');

if (moment(start, config.model.dateformat).isValid() &&
moment(end, config.model.dateformat).isValid()
if (moment(start, appConfig.model.dateformat).isValid() &&
moment(end, appConfig.model.dateformat).isValid()
) {
return formatDate(moment, config, start) +
' - ' +
formatDate(moment, config, end);
return formatDate(start) + ' - ' + formatDate(end);
}
},
[DATE_FILTERS.DAY]: () => (
moment(_.get(params, 'dates.date'), config.model.dateformat)
moment(_.get(params, 'dates.date'), appConfig.model.dateformat)
.format('dddd Do MMMM YYYY')
),

Expand Down
4 changes: 4 additions & 0 deletions client/charts/tests/ChartConfig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ describe('chartConfig', () => {
config = {};
}));

beforeEach(inject(($httpBackend) => {
$httpBackend.whenGET(/api$/).respond({_links: {child: []}});
}));

mockAll();

const genSingleChart = (chartId, chartType) => {
Expand Down
4 changes: 4 additions & 0 deletions client/charts/tests/sd-chart-container.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ describe('sda-chart-container', () => {
$timeout = _$timeout_;
}));

beforeEach(inject(($httpBackend) => {
$httpBackend.whenGET(/api$/).respond({_links: {child: []}});
}));

beforeEach(() => {
configs = [{
id: 'test-chart-1',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {appConfig} from 'superdesk-core/scripts/appConfig';

import {getErrorMessage} from '../../utils';
import {CHART_TYPES} from '../../charts/directives/ChartOptions';

Expand All @@ -10,7 +12,6 @@ ContentPublishingReportController.$inject = [
'searchReport',
'notify',
'moment',
'config',
'$q',
'chartConfig',
'$interpolate',
Expand All @@ -29,7 +30,6 @@ ContentPublishingReportController.$inject = [
* @requires searchReport
* @requires notify
* @requires moment
* @requires config
* @requires $q
* @requires chartConfig
* @requires $interpolate
Expand All @@ -45,7 +45,6 @@ export function ContentPublishingReportController(
searchReport,
notify,
moment,
config,
$q,
chartConfig,
$interpolate,
Expand Down Expand Up @@ -94,8 +93,8 @@ export function ContentPublishingReportController(
filter: 'range',
start: moment()
.subtract(30, 'days')
.format(config.model.dateformat),
end: moment().format(config.model.dateformat),
.format(appConfig.model.dateformat),
end: moment().format(appConfig.model.dateformat),
},
must: {},
must_not: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {appConfig} from 'superdesk-core/scripts/appConfig';

import {
getErrorMessage,
getUtcOffsetInMinutes,
Expand All @@ -19,8 +21,6 @@ DeskActivityReportController.$inject = [
'gettext',
'gettextCatalog',
'$q',
'config',
'deployConfig',
'desks',
'reportConfigs',
];
Expand All @@ -39,8 +39,6 @@ DeskActivityReportController.$inject = [
* @requires gettext
* @requires gettextCatalog
* @requires $q
* @requires config
* @requires deployConfig
* @requires desks
* @requires reportConfigs
* @description Controller for Desk Activity Reports
Expand All @@ -56,8 +54,6 @@ export function DeskActivityReportController(
gettext,
gettextCatalog,
$q,
config,
deployConfig,
desks,
reportConfigs
) {
Expand Down Expand Up @@ -138,8 +134,8 @@ export function DeskActivityReportController(
filter: 'range',
start: moment()
.subtract(30, 'days')
.format(config.model.dateformat),
end: moment().format(config.model.dateformat),
.format(appConfig.model.dateformat),
end: moment().format(appConfig.model.dateformat),
},
must: {},
must_not: {},
Expand Down Expand Up @@ -353,16 +349,15 @@ export function DeskActivityReportController(
// Any data after the daylight savings change will be 1 hour out
const utcOffset = getUtcOffsetInMinutes(
report.start,
config.defaultTimezone,
moment
appConfig.defaultTimezone
);

const chart = new SDChart.Chart({
id: reportName,
chartType: 'highcharts',
title: $scope.generateTitle(),
subtitle: $scope.generateSubtitle(),
startOfWeek: deployConfig.getSync('start_of_week', 0),
startOfWeek: appConfig.start_of_week || appConfig.startingDay || 0,
timezoneOffset: utcOffset,
useUTC: false,
fullHeight: false,
Expand Down
4 changes: 4 additions & 0 deletions client/directives/tests/sda-analytics-container.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ describe('sda-analytics-container', () => {
scope = $rootScope.$new();
}));

beforeEach(inject(($httpBackend) => {
$httpBackend.whenGET(/api$/).respond({_links: {child: []}});
}));

const initContainer = () => {
// Construct the analytics container
$compile('<div sda-analytics-container></div>')(scope);
Expand Down
4 changes: 4 additions & 0 deletions client/directives/tests/sda-convert-to-number.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe('sda-convert-to-number', () => {
$rootScope = _$rootScope_;
}));

beforeEach(inject(($httpBackend) => {
$httpBackend.whenGET(/api$/).respond({_links: {child: []}});
}));

it('passes an integer into the directive', () => {
scope = $rootScope.$new();
scope.item = {number: 25};
Expand Down
4 changes: 4 additions & 0 deletions client/directives/tests/sda-report-dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ describe('sda-report-dropdown', () => {
$rootScope = _$rootScope_;
}));

beforeEach(inject(($httpBackend) => {
$httpBackend.whenGET(/api$/).respond({_links: {child: []}});
}));

beforeEach(() => {
reports = [
{},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {appConfig} from 'superdesk-core/scripts/appConfig';

import {getErrorMessage} from '../../utils';
import {CHART_FIELDS, CHART_TYPES} from '../../charts/directives/ChartOptions';
import {DATE_FILTERS} from '../../search/common';
Expand All @@ -11,7 +13,6 @@ FeaturemediaUpdatesReportController.$inject = [
'searchReport',
'notify',
'moment',
'config',
'$q',
'chartConfig',
'reportConfigs',
Expand All @@ -29,7 +30,6 @@ FeaturemediaUpdatesReportController.$inject = [
* @requires searchReport
* @requires notify
* @requires moment
* @requires config
* @requires $q
* @requires chartConfig
* @requires reportConfigs
Expand All @@ -44,7 +44,6 @@ export function FeaturemediaUpdatesReportController(
searchReport,
notify,
moment,
config,
$q,
chartConfig,
reportConfigs
Expand Down Expand Up @@ -98,8 +97,8 @@ export function FeaturemediaUpdatesReportController(
filter: DATE_FILTERS.RANGE,
start: moment()
.subtract(30, 'days')
.format(config.model.dateformat),
end: moment().format(config.model.dateformat),
.format(appConfig.model.dateformat),
end: moment().format(appConfig.model.dateformat),
},
must: {},
must_not: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {appConfig} from 'superdesk-core/scripts/appConfig';

import {getTranslatedOperations} from '../../utils';

FeaturemediaUpdatesTable.$inject = [
'gettext',
'userList',
'moment',
'config',
'api',
'lodash',
'searchReport',
Expand All @@ -18,7 +19,6 @@ FeaturemediaUpdatesTable.$inject = [
* @requires gettext
* @requires userList
* @requires moment
* @requires config
* @requires api
* @requires lodash
* @requires searchReport
Expand All @@ -29,7 +29,6 @@ export function FeaturemediaUpdatesTable(
gettext,
userList,
moment,
config,
api,
_,
searchReport,
Expand Down Expand Up @@ -84,7 +83,7 @@ export function FeaturemediaUpdatesTable(
const operations = getTranslatedOperations(gettext);

const genDateStr = (date) => (
moment(date).format(config.view.dateformat + ' ' + config.view.timeformat)
moment(date).format(appConfig.view.dateformat + ' ' + appConfig.view.timeformat)
);

scope.itemUpdates = [];
Expand Down
Loading