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

refactor(subject previews): allow for single series JSON data subjects #7123

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Jun 6, 2024

Refactor previews for JSON data subjects to include subjects with a single x,y data series eg. PH-TESS subjects. getDatasets(data) reflects on the type of data, then calls an appropriate helper function to convert data into an array of chart.js datasets.

You can check the subject viewer for a JSON data subject on Black Hole Hunters Talk
eg. https://local.zooniverse.org:3735/projects/cobalt-lensing/black-hole-hunters/talk/subjects/96013284?env=production

Required Manual Testing

  • Does the non-logged in home page render correctly?
  • Does the logged in home page render correctly?
  • Does the projects page render correctly?
  • Can you load project home pages?
  • Can you load the classification page?
  • Can you submit a classification?
  • Does talk load correctly?
  • Can you post a talk comment?

Review Checklist

  • Does it work in all major browsers: Firefox, Chrome, Edge, Safari?
  • Does it work on mobile?
  • Can you npm ci and app works as expected?
  • If the component is in coffeescript, is it converted to ES6? Is it free of eslint errors? Is the conversion its own commit?
  • Are the tests passing locally and on GitHub Actions?

Optional

@coveralls
Copy link

Coverage Status

coverage: 56.953% (-0.04%) from 56.991%
when pulling db27228 on eatyourgreens:data-subject-preview
into 1ca8532 on zooniverse:master.

Comment on lines +3 to +10
function getXYData(data) {
return {
data: data.x.map((x, index) => ({ x, y: data.y[index] })),
pointStyle: 'circle',
backgroundColor: '#ffffff',
borderColor: '#000000'
}
}
Copy link
Contributor Author

@eatyourgreens eatyourgreens Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new, to handle subjects with { data: { x: number[], y: number[] }}. Otherwise, the rest of the code in this PR should be unchanged from the original, just refactored into smaller functions.

@coveralls
Copy link

Coverage Status

coverage: 56.943% (-0.05%) from 56.991%
when pulling c6031ce on eatyourgreens:data-subject-preview
into 1ca8532 on zooniverse:master.

Comment on lines 44 to 55
if(data.x && data.y) {
return {
data: {
x: data.x,
y: data.y
}
});
}
if (data.datasets) {
datasets = data.datasets
},
{
chartOptions: {
xAxisLabel: 'Days',
yAxisLabel: 'Brightness'
}
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This converts PH-TESS subjects from { x, y } to { data: { x, y }, chartOptions } (when the location MIME type is application/json.)

@coveralls
Copy link

Coverage Status

coverage: 56.941% (-0.05%) from 56.991%
when pulling 6224b59 on eatyourgreens:data-subject-preview
into 1ca8532 on zooniverse:master.

@eatyourgreens eatyourgreens force-pushed the data-subject-preview branch from 9b1096c to c901cfe Compare June 6, 2024 15:04
@coveralls
Copy link

Coverage Status

coverage: 56.941% (-0.05%) from 56.991%
when pulling 9b1096c on eatyourgreens:data-subject-preview
into 1ca8532 on zooniverse:master.

@coveralls
Copy link

Coverage Status

coverage: 56.941% (-0.05%) from 56.994%
when pulling c901cfe on eatyourgreens:data-subject-preview
into a698f8c on zooniverse:master.

@coveralls
Copy link

Coverage Status

coverage: 56.932% (-0.06%) from 56.994%
when pulling 09fb922 on eatyourgreens:data-subject-preview
into a698f8c on zooniverse:master.

@eatyourgreens eatyourgreens force-pushed the data-subject-preview branch from 09fb922 to b863e9b Compare June 8, 2024 01:41
@coveralls
Copy link

Coverage Status

coverage: 56.932% (-0.06%) from 56.991%
when pulling b863e9b on eatyourgreens:data-subject-preview
into b19edc1 on zooniverse:master.

@eatyourgreens eatyourgreens force-pushed the data-subject-preview branch from b863e9b to e11b0e8 Compare June 18, 2024 14:57
@coveralls
Copy link

Coverage Status

coverage: 56.929% (-0.07%) from 56.994%
when pulling e11b0e8 on eatyourgreens:data-subject-preview
into 408ffca on zooniverse:master.

Refactor previews for JSON data subjects to include subjects with a single `x,y` data series. `getDatasets(data)` reflects on the type of data, then calls an appropriate helper function to convert `data` into an array of `chart.js` datasets.
@eatyourgreens eatyourgreens force-pushed the data-subject-preview branch from e11b0e8 to 939d235 Compare July 17, 2024 14:45
@coveralls
Copy link

Coverage Status

coverage: 56.865% (-0.08%) from 56.948%
when pulling 939d235 on eatyourgreens:data-subject-preview
into 2d0f81a on zooniverse:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants