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

Split reports code #3185

Merged
merged 6 commits into from May 17, 2021
Merged

Split reports code #3185

merged 6 commits into from May 17, 2021

Conversation

magicznyleszek
Copy link
Member

Description

Split Reports code into multiple files to make maintaining it easier.

Additional details

This is mostly just moving all classes defined in reports.es6 into their separate files. Also cleaned up linter warnings and defined one new constant.

Did it as "nice to have" thing while fixing #3183 (I had to rebuild project multiple times due to Enketo issues so had some time to kill).

@magicznyleszek magicznyleszek requested a review from duvld May 6, 2021 17:45
@magicznyleszek magicznyleszek changed the base branch from master to beta May 6, 2021 17:45

defaultReportColorsChange(evt) {
this.props.onChange(
{ default: true },
Copy link
Member

Choose a reason for hiding this comment

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

Should've asked a while ago, are you using any specific Prettier settings (like in a .prettierrc)? Usually we don't have a space padding around brackets like this but I know it's a default in Prettier linting

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, so I think that my prettier (I use default with few rules being based on our .editorconfig) and our .eslintrc.json differ as to spaces in this situation. I was used to removing (as this matches how we handle ( and [, etc.).

I also have lines mergin in my editor, and when used it always adds a space between merged lines, resulting in { default: true },. I think I merged those and missed that.

Maybe it's a good moment to add .prettierrc file to our repo? Not to automatically use it right now, but to decide on what's in it for future.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's a good moment to add .prettierrc file to our repo? Not to automatically use it right now, but to decide on what's in it for future.

Yeah I agree, just so we're consistent with what our linters are doing for new code :D

if (resps) {
reportData[i].data.responseLabels = [];
for (var j = resps.length - 1; j >= 0; j--) {
choice = asset.content.choices.find((o) => {
Copy link
Member

Choose a reason for hiding this comment

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

wow this section was hard to read before 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

hah, still isn't best :D

if (vals && vals[0] && vals[0][1] && vals[0][1].responses) {
var respValues = vals[0][1].responses;
reportData[i].data.responseLabels = [];
let qGB = asset.content.survey.find((z) => {return z.name === groupBy || z.$autoname === groupBy});
Copy link
Member

Choose a reason for hiding this comment

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

why did these lines not get split into multiple?

(o.name === r || o.$autoname === r)
);
});
reportData[i].data.responseLabels[ind] = (choice && choice.label && choice.label[tnslIndex]) ? choice.label[tnslIndex] : r;
Copy link
Member

Choose a reason for hiding this comment

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

same as above (actually a couple more across all files)

let rowsByKuid = {};
let rowsByIdentifier = {};
let groupBy = '',
reportStyles = asset.report_styles,
Copy link
Member

Choose a reason for hiding this comment

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

it looked like the linting expanded variable declarations from let x, y into let x; let y;. maybe a missed spot here?
same thing on line 150

@duvld duvld merged commit 452073d into beta May 17, 2021
@duvld duvld deleted the split-reports-code branch May 17, 2021 14:34
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.

None yet

2 participants