diff --git a/app/locales/en.js b/app/locales/en.js index 340f3ec642..0e223f0051 100644 --- a/app/locales/en.js +++ b/app/locales/en.js @@ -162,16 +162,16 @@ export default { retiredSubjects: 'Completed Subjects', subjects: 'Subjects' }, - classification: 'Classifications', - comment: 'Talk Comments', + classifications: 'Classifications', + comments: 'Talk Comments', dateRange: 'Date range', expandWorkflowStats: 'Expand Workflow Stats', for: 'for', hidden: 'Stats hidden', hourly: 'Hourly data only available for the most recent 2 weeks.', organizationStatistics: '%(title)s Statistics', - perclassification: 'Classifications per', - percomment: 'Comments per', + perclassifications: 'Classifications per', + percomments: 'Comments per', projectStats: 'Live Projects (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/hi.js b/app/locales/hi.js index f9e1f94c4b..2c555795b6 100644 --- a/app/locales/hi.js +++ b/app/locales/hi.js @@ -142,16 +142,16 @@ export default { retiredSubjects: 'पूर्ण विषय', subjects: 'विषय' }, - classification: 'श्रेणियां', - comment: 'बात, चर्चा', + classifications: 'श्रेणियां', + comments: 'बात, चर्चा', dateRange: 'दिनांक की रेंज ', expandWorkflowStats: 'कार्य गति विस्तार की सांख्यिकी ', for: 'के लिए', hidden: 'छुपे ', hourly: 'घंटेवार डेटा सिर्फ विगत २ हफ़्तों के लिए उपलब्ध है', organizationStatistics: '%(title)s के आँकड़े', - perclassification: 'हर श्रेणीयां', - percomment: 'हर कमेंट', + perclassifications: 'हर श्रेणीयां', + percomments: 'हर कमेंट', projectStats: 'जारी परियोजनाएं (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/ja.js b/app/locales/ja.js index b94ccbc0de..59c6cad171 100644 --- a/app/locales/ja.js +++ b/app/locales/ja.js @@ -162,16 +162,16 @@ export default { retiredSubjects: '完了した画像', subjects: '画像' }, - classification: '分類', - comment: 'トークのコメント', + classifications: '分類', + comments: 'トークのコメント', dateRange: '日付の範囲', expandWorkflowStats: 'ワークフロー統計を展開', for: '対象', hidden: '統計を非表示', hourly: '1時間ごとのデータは直近2週間分のみ利用可能です。', organizationStatistics: '%(title)s 統計', - perclassification: 'あたりの分類', - percomment: 'あたりのコメント', + perclassifications: 'あたりの分類', + percomments: 'あたりのコメント', projectStats: '進行中のプロジェクト (%(count)s)', reset: '表示をリセット' } diff --git a/app/locales/kn.js b/app/locales/kn.js index 210960e3e8..25fcf4e0ed 100644 --- a/app/locales/kn.js +++ b/app/locales/kn.js @@ -162,16 +162,16 @@ export default { retiredSubjects: 'Completed Subjects', subjects: 'Subjects' }, - classification: 'Classifications', - comment: 'Talk Comments', + classifications: 'Classifications', + comments: 'Talk Comments', dateRange: 'Date range', expandWorkflowStats: 'Expand Workflow Stats', for: 'for', hidden: 'Stats hidden', hourly: 'Hourly data only available for the most recent 2 weeks.', organizationStatistics: '%(title)s Statistics', - perclassification: 'Classifications per', - percomment: 'Comments per', + perclassifications: 'Classifications per', + percomments: 'Comments per', projectStats: 'Live Projects (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/ko.js b/app/locales/ko.js index 210960e3e8..25fcf4e0ed 100644 --- a/app/locales/ko.js +++ b/app/locales/ko.js @@ -162,16 +162,16 @@ export default { retiredSubjects: 'Completed Subjects', subjects: 'Subjects' }, - classification: 'Classifications', - comment: 'Talk Comments', + classifications: 'Classifications', + comments: 'Talk Comments', dateRange: 'Date range', expandWorkflowStats: 'Expand Workflow Stats', for: 'for', hidden: 'Stats hidden', hourly: 'Hourly data only available for the most recent 2 weeks.', organizationStatistics: '%(title)s Statistics', - perclassification: 'Classifications per', - percomment: 'Comments per', + perclassifications: 'Classifications per', + percomments: 'Comments per', projectStats: 'Live Projects (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/pl.js b/app/locales/pl.js index 8b39f23afd..2154b87f35 100644 --- a/app/locales/pl.js +++ b/app/locales/pl.js @@ -154,16 +154,16 @@ export default { retiredSubjects: 'Completed Subjects', subjects: 'Subjects' }, - classification: 'Classifications', - comment: 'Talk Comments', + classifications: 'Classifications', + comments: 'Talk Comments', dateRange: 'Date range', expandWorkflowStats: 'Expand Workflow Stats', for: 'for', hidden: 'Stats hidden', hourly: 'Hourly data only available for the most recent 2 weeks.', organizationStatistics: '%(title)s statystyka', - perclassification: 'Classifications per', - percomment: 'Comments per', + perclassifications: 'Classifications per', + percomments: 'Comments per', projectStats: 'Live Projects (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/ru.js b/app/locales/ru.js index 8c1f65cc70..28724c5164 100644 --- a/app/locales/ru.js +++ b/app/locales/ru.js @@ -164,16 +164,16 @@ export default { retiredSubjects: 'Completed Subjects', subjects: 'Subjects' }, - classification: 'Classifications', - comment: 'Talk Comments', + classifications: 'Classifications', + comments: 'Talk Comments', dateRange: 'Date range', expandWorkflowStats: 'Expand Workflow Stats', for: 'for', hidden: 'Stats hidden', hourly: 'Hourly data only available for the most recent 2 weeks.', organizationStatistics: '%(title)s Statistics', - perclassification: 'Classifications per', - percomment: 'Comments per', + perclassifications: 'Classifications per', + percomments: 'Comments per', projectStats: 'Live Projects (%(count)s)', reset: 'Reset view' } diff --git a/app/locales/sv.js b/app/locales/sv.js index 1893ebe068..724bb4742c 100644 --- a/app/locales/sv.js +++ b/app/locales/sv.js @@ -162,16 +162,16 @@ export default { retiredSubjects: 'Avslutade ämnen', subjects: 'Ämnen' }, - classification: 'Klassificeringar', - comment: 'Kommentarer', + classifications: 'Klassificeringar', + comments: 'Kommentarer', dateRange: 'Spann i datum', expandWorkflowStats: 'Expandera statistik för arbetsflöde', for: 'för', hidden: 'Statistik dold', hourly: 'Data timme för timme finns endast för de senaste 2 veckorna.', organizationStatistics: '%(title)s statistik', - perclassification: 'Klassificeringar', - percomment: 'Kommentar per', + perclassifications: 'Klassificeringar', + percomments: 'Kommentar per', projectStats: 'Pågående projekt (%(count)s)', reset: 'Återställ' } diff --git a/app/locales/tr.js b/app/locales/tr.js index d1221d3992..2ac0086323 100644 --- a/app/locales/tr.js +++ b/app/locales/tr.js @@ -162,16 +162,16 @@ export default { retiredSubjects: 'Tamamlanan Temalar', subjects: 'Temalar' }, - classification: 'Sınıflandırmalar', - comment: 'Sohbet Yorumları', + classifications: 'Sınıflandırmalar', + comments: 'Sohbet Yorumları', dateRange: 'Tarih aralığı', expandWorkflowStats: 'İş Akışı İstatistiklerini Genişlet', for: 'için', hidden: 'İstatistikler gizlendi', hourly: 'Yalnızca en son 2 haftaya ait saatlik veriler mevcuttur.', organizationStatistics: '%(title)s İstatistikler', - perclassification: 'Sınıflandırmalar', - percomment: 'Yorumlar ', + perclassifications: 'Sınıflandırmalar', + percomments: 'Yorumlar ', projectStats: 'Devam Eden Projeler (%(count)s)', reset: 'Görünümü sıfırla' } diff --git a/app/locales/ur.js b/app/locales/ur.js index 92e5257a16..f777ed2c97 100644 --- a/app/locales/ur.js +++ b/app/locales/ur.js @@ -142,16 +142,16 @@ export default { retiredSubjects: 'مکمل مضامین', subjects: ' مضامین' }, - classification: 'درجہ بندیاں', - comment: 'تبصرے', + classifications: 'درجہ بندیاں', + comments: 'تبصرے', dateRange: 'تاریخ کا عرصہ', expandWorkflowStats: 'ورک فلو کے اعدادوشمار کو وسیع کریں', for: 'کے لئے', hidden: 'پوشیدہ اعداد و شمار ', hourly: 'حالیہ 2 ہفتوں کا ہی گھنٹہ وارانہ ڈیٹا دستیاب ہے۔', organizationStatistics: '(عنوان) کے اعدادوشمار', - perclassification: 'درجہ بندی فی', - percomment: 'تبصرے فی ', + perclassifications: 'درجہ بندی فی', + percomments: 'تبصرے فی ', projectStats: 'لایئو پروجیکٹس(%(count)s)', reset: 'بصری معائنہ کو ترتیب دیں۔ ' } diff --git a/app/pages/home-not-logged-in.jsx b/app/pages/home-not-logged-in.jsx index b66c700c8f..30f312cae3 100644 --- a/app/pages/home-not-logged-in.jsx +++ b/app/pages/home-not-logged-in.jsx @@ -1,6 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import { Link } from 'react-router'; +import statsClient from 'panoptes-client/lib/eras-client'; import Translate from 'react-translate-component'; import counterpart from 'counterpart'; import apiClient from 'panoptes-client/lib/api-client'; @@ -11,10 +12,6 @@ import HomePageSocial from './home-common/social'; import HomePageDiscover from './home-not-logged-in/discover'; import HomePageResearch from './home-not-logged-in/research'; -const ERAS_STATS_URL = (process.env.NODE_ENV === 'staging' || process.env.NODE_ENV === 'development') - ? 'https://eras-staging.zooniverse.org' - : 'https://eras.zooniverse.org'; - counterpart.registerTranslations('en', { notLoggedInHomePage: { projects: 'See All Projects', @@ -67,17 +64,13 @@ export default class HomePage extends React.Component { } getClassificationCounts() { - fetch(ERAS_STATS_URL + '/classifications').then((response) => { - if (!response.ok) { - console.error('ERAS STATS CLASSIFICATIONS COUNT NONLOGGED IN HOMEPAGE: ERROR') - throw Error(response.statusText); - } - return response.json() + statsClient.query({ + type: 'classifications' }).then(data => { let count = data.total_count this.setState({ count }); }).catch((err) => { - console.error('ERAS TOTAL CLASSIFICATION COUNT: from ' + ERAS_STATS_URL + '/classifications', err) + console.error('COULD NOT RETRIEVE ERAS TOTAL CLASSIFICATION COUNT', err) }) } diff --git a/app/pages/organization/stats/OrganizationStats.jsx b/app/pages/organization/stats/OrganizationStats.jsx index 1a1b7eb757..e4d51d4520 100644 --- a/app/pages/organization/stats/OrganizationStats.jsx +++ b/app/pages/organization/stats/OrganizationStats.jsx @@ -69,11 +69,11 @@ function OrganizationStats({ diff --git a/app/pages/organization/stats/components/BarChart/BarChartContainer.jsx b/app/pages/organization/stats/components/BarChart/BarChartContainer.jsx index fbd63c522f..e9b1594288 100644 --- a/app/pages/organization/stats/components/BarChart/BarChartContainer.jsx +++ b/app/pages/organization/stats/components/BarChart/BarChartContainer.jsx @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; -import statsClient from 'panoptes-client/lib/stats-client'; +import statsClient from 'panoptes-client/lib/eras-client'; import fillTimeSeries from './helpers/fillTimeSeries'; import filterTimeSeries from './helpers/filterTimeSeries'; @@ -61,15 +61,15 @@ class BarChartContainer extends React.Component { const query = { period: binBy, projectID, - type + type, }; return statsClient .query(query) - .then(data => ( - data.map(statObject => ({ - label: statObject.key_as_string, - value: statObject.doc_count + .then(response => ( + response?.data.map(statObject => ({ + label: statObject.period, + value: statObject.count })) )).then(data => ( fillTimeSeries(data, binBy) diff --git a/app/pages/organization/stats/components/BarChart/components/Parameters.jsx b/app/pages/organization/stats/components/BarChart/components/Parameters.jsx index bd07e4191f..08c16932c2 100644 --- a/app/pages/organization/stats/components/BarChart/components/Parameters.jsx +++ b/app/pages/organization/stats/components/BarChart/components/Parameters.jsx @@ -8,7 +8,6 @@ import formatLabel from '../helpers/formatLabel'; import Select from './Select'; export const binByOptions = [ - { label: 'hour', value: 'hour' }, { label: 'day', value: 'day' }, { label: 'week', value: 'week' }, { label: 'month', value: 'month' } @@ -177,12 +176,6 @@ function Parameters({ content="organization.stats.reset" /> - {binBy === 'hour' && ( - - )} ); diff --git a/app/pages/organization/stats/components/BarChart/components/Parameters.spec.js b/app/pages/organization/stats/components/BarChart/components/Parameters.spec.js index 749a8e1069..25d069c0fc 100644 --- a/app/pages/organization/stats/components/BarChart/components/Parameters.spec.js +++ b/app/pages/organization/stats/components/BarChart/components/Parameters.spec.js @@ -55,9 +55,4 @@ describe('Parameters', function () { .to.have.lengthOf(0); }); - it('should render hourly warning if binBy is hour', function () { - wrapper.setProps({ binBy: 'hour' }); - expect(wrapper.find(Translate).filterWhere(n => n.prop('content') === 'organization.stats.hourly')) - .to.have.lengthOf(1); - }); }); diff --git a/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.js b/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.js index a2afa8671a..24855bbf85 100644 --- a/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.js +++ b/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.js @@ -6,9 +6,6 @@ function fillTimeSeries(series = [], by = 'day', notEarlierThan = twoWeeksBefore const filledSeries = []; let previousLabel = ''; series.forEach(({ label, value }) => { - if (by === 'hour' && moment.utc(label) <= notEarlierThan) { - return; - } const difference = moment.utc(label).diff(moment.utc(previousLabel), `${by}s`); if (difference > 1) { diff --git a/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.spec.js b/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.spec.js index ee767c4b73..e73cbe7128 100644 --- a/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.spec.js +++ b/app/pages/organization/stats/components/BarChart/helpers/fillTimeSeries.spec.js @@ -39,9 +39,4 @@ describe('fillTimeSeries', function () { it('should return a series including dates with zero value', function () { expect(fillTimeSeries(mockDaySeries, 'day')).to.eql(mockDaySeriesFilled); }); - - it('should return a series by hour not earlier than two weeks before now', function () { - const notEarlierThan = moment.utc('2019-01-09T03:00:00.000Z'); - expect(fillTimeSeries(mockHourSeries, 'hour', notEarlierThan)).to.eql(mockHourSeriesFilled); - }); }); diff --git a/app/pages/project/stats/index.jsx b/app/pages/project/stats/index.jsx index a7b30ded1c..a0ba7ec8ac 100644 --- a/app/pages/project/stats/index.jsx +++ b/app/pages/project/stats/index.jsx @@ -98,9 +98,9 @@ class ProjectStatsPageController extends React.Component { handleGraphChange: this.handleGraphChange, handleRangeChange: this.handleRangeChange, handleWorkflowChange: this.handleWorkflowChange, - classificationsBy: this.getQuery('classification') || 'day', + classificationsBy: this.getQuery('classifications') || 'day', classificationRange: this.getQuery('classificationRange'), - commentsBy: this.getQuery('comment') || 'day', + commentsBy: this.getQuery('comments') || 'day', commentRange: this.getQuery('commentRange'), projectId: this.props.project.id, workflowId: this.getQuery('workflow_id'), diff --git a/app/pages/project/stats/stats.jsx b/app/pages/project/stats/stats.jsx index dca9f5bc16..ecfa2926bd 100644 --- a/app/pages/project/stats/stats.jsx +++ b/app/pages/project/stats/stats.jsx @@ -1,6 +1,6 @@ import PropTypes from 'prop-types'; import React from 'react'; -import statsClient from 'panoptes-client/lib/stats-client'; +import statsClient from 'panoptes-client/lib/eras-client'; import moment from 'moment'; import { Progress, Graph } from './charts.jsx'; @@ -41,17 +41,20 @@ export class GraphSelect extends React.Component { } getStats(workflowId, binBy) { + const queryObj = { + workflowID: workflowId, + period: binBy, + type: this.props.type, + } + if (this.props.type === 'comments' || !workflowId) { + queryObj.projectID = this.props.projectId; + } statsClient - .query({ - projectID: this.props.projectId, - workflowID: workflowId, - period: binBy, - type: this.props.type, - }) - .then((data) => ( - data.map((statObject) => ({ - label: statObject.key_as_string, - value: statObject.doc_count, + .query(queryObj) + .then((response) => ( + response?.data.map((statObject) => ({ + label: statObject.period, + value: statObject.count, })) )) .then((statData) => { @@ -138,9 +141,8 @@ export class GraphSelect extends React.Component { const workflowSelect = this.workflowSelect(); output = (
- {this.props.type[0].toUpperCase() + this.props.type.substring(1)}s per{' '} + {this.props.type[0].toUpperCase() + this.props.type.substring(1)} per{' '}