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

Replace stats with eras client #6974

Merged
merged 10 commits into from
Dec 6, 2023
8 changes: 4 additions & 4 deletions app/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/hi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/ja.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '表示をリセット'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/kn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/tr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
8 changes: 4 additions & 4 deletions app/locales/ur.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: 'بصری معائنہ کو ترتیب دیں۔ '
}
Expand Down
15 changes: 4 additions & 11 deletions app/pages/home-not-logged-in.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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',
Expand Down Expand Up @@ -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)
})
}

Expand Down
4 changes: 2 additions & 2 deletions app/pages/organization/stats/OrganizationStats.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ function OrganizationStats({
<StatsContainer>
<BarChart
projects={organizationProjects}
type="classification"
type="classifications"
/>
<BarChart
projects={organizationProjects}
type="comment"
type="comments"
/>
</StatsContainer>
<StatsContainer>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down Expand Up @@ -177,12 +176,6 @@ function Parameters({
content="organization.stats.reset"
/>
</StyledResetButton>
{binBy === 'hour' && (
<Translate
component={StyledWarning}
content="organization.stats.hourly"
/>
)}
</StyledResetContainer>
</StyledParametersContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
4 changes: 2 additions & 2 deletions app/pages/project/stats/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Loading