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{' '}