Skip to content

Commit

Permalink
update non logged in home page to call out to ERAS stats service (#6925)
Browse files Browse the repository at this point in the history
* update non logged in home page to call out to ERAS stats service

* remove no longer used import of statsClient

---------

Co-authored-by: Mark Bouslog <[email protected]>
  • Loading branch information
yuenmichelle1 and mcbouslog authored Nov 7, 2023
1 parent abbf841 commit 7f1c3a4
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions app/pages/home-not-logged-in.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import { Link } from 'react-router';
import statsClient from 'panoptes-client/lib/stats-client';
import Translate from 'react-translate-component';
import counterpart from 'counterpart';
import apiClient from 'panoptes-client/lib/api-client';
Expand All @@ -12,6 +11,10 @@ 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 @@ -64,17 +67,18 @@ export default class HomePage extends React.Component {
}

getClassificationCounts() {
let count = 0;
statsClient.query({
period: 'year',
type: 'classification'
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()
}).then(data => {
let count = data.total_count
this.setState({ count });
}).catch((err) => {
console.error('ERAS TOTAL CLASSIFICATION COUNT: from ' + ERAS_STATS_URL + '/classifications', err)
})
.then((data) => {
data.map((statObject) => {
count += statObject.doc_count;
});
this.setState({ count }); // number will only appear on production
});
}

showDialog(event) {
Expand Down

0 comments on commit 7f1c3a4

Please sign in to comment.