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

Address #309, arrange variables in dropdown menu #310

Merged
merged 1 commit into from
Jul 10, 2019
Merged

Conversation

corviday
Copy link
Contributor

@corviday corviday commented Jul 9, 2019

Currently, the order variables appear in the variable selection dropdown menu matches the order the first instance of each variable appears in the multimeta query. Historically, this has worked adequately for us, because we have added data in stages. We started with model output, then added climdex data, then degree day data, and finally return period data.

The multimeta query returns datasets in no particular order, but it approximates the order they were added to the database well enough, so historically variables have appeared in the menu with the related variables that were added at the same time. All the model outputs together, all the degree days together, etc.

Unfortunately, I just updated a bunch of data ( pacificclimate/climate-explorer-data-prep#73 ) and now the order modelmeta is returning data in is a lot less convenient and the default is a much more confusing menu. Many of the updated climdex variables now appear at the end of the variable dropdown, far separated from the rest of the climdex variables, and much harder to find (or look up in the help).

This PR orders the variables inside the variable selection dropdown. Variables are assigned into numerical "menu groups" via the new menuGroup attribute in the variable configuration file. The menu groups could be anything, but in this case, they're set to correspond to the groupings used in the data documentation:

  1. model output data
  2. climdex data
  3. degree day data
  4. return period data

Variables not assigned to any group by the variable configuration file are assigned to group MAX_SAFE_INTEGER and appear at the end of the menu. With each group, variables are listed in alphabetical order.

This is something of a temporary patch; long term variable selection is expected to work completely differently ( #216 ) . However, I think short term, making it easier to look up variables in the help file and find related variables is worth this quick fix.

Resolves #309

Copy link
Contributor

@rod-glover rod-glover left a comment

Choose a reason for hiding this comment

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

LGTM

return _.isUndefined(membership) ? Number.MAX_SAFE_INTEGER : membership;});
groups = _.map(groups, g=> {return _.sortBy(g, 'variable_id');});
return _.flatten(groups);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Underscore is pretty great. :)

@corviday corviday merged commit 2e2b9a1 into master Jul 10, 2019
@corviday corviday deleted the feature/309 branch July 10, 2019 18:38
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.

Add a way to control the order variables appear in the dropdown
2 participants