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 demographics utilities #329

Merged
merged 4 commits into from
Feb 1, 2021
Merged

Conversation

macfarlandian
Copy link
Collaborator

@macfarlandian macfarlandian commented Jan 28, 2021

Description of the change

I have never been very happy with the solution I came up with for dealing with demographic data in this applications — all the mappings of known categories for race, gender, and age that lined up with each other and the data from the server. The move from v1 to v2 seemed to make this worse rather than better and I was finding this code very hard to work with as I started on the linked ticket. I don't think it was super fun to review in #316 either. This seemed like an opportune moment to try to do something about it before more classes started depending on it.

A summary of the changes:

  • the names of the "demographic views" and the corresponding field keys are now the same. Unlike in v1, we have already renamed the field keys from the raw files, so there's no reason not to make the names more useful in context. This eliminates one of the mapping steps and also let us just use the list of demographic views for both purposes
  • Instead of passing around raw mapping objects for iteration, there is now just a function to request a list of all categories for a particular view. This includes filtering out "unknown" values, which we basically always want to do, so that is no longer a manual step either.
  • nearly everything demographic-related is consolidated in the demographics directory instead of some of it being arbitrarily housed in metricsApi. There's a little bit still in the old directory that is only directly relevant to the responsibilities of the metricsApi modules.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Configuration change (adjusts configuration to achieve some end related to functionality, development, performance, or security)

Related issues

part of #296

Checklists

Development

These boxes should be checked by the submitter prior to merging:

  • Manual testing against realistic data has been performed locally

Code review

These boxes should be checked by reviewers prior to merging:

  • This pull request has a descriptive title and information useful to a reviewer
  • This pull request has been moved out of a Draft state, has no "Work In Progress" label, and has assigned reviewers
  • Potential security implications or infrastructural changes have been considered, if relevant

@coveralls
Copy link

coveralls commented Jan 28, 2021

Pull Request Test Coverage Report for Build 521705231

  • 36 of 37 (97.3%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 66.002%

Changes Missing Coverage Covered Lines Changed/Added Lines %
spotlight-client/src/demographics/utils.ts 19 20 95.0%
Totals Coverage Status
Change from base Build 521696848: 0.02%
Covered Lines: 1749
Relevant Lines: 2563

💛 - Coveralls

@macfarlandian
Copy link
Collaborator Author

got a little overzealous there with removing the "nofilter" value ... turns out we do actually need it and I was just confused!

Copy link

@jovergaag jovergaag left a comment

Choose a reason for hiding this comment

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

Looks great.

@macfarlandian macfarlandian merged commit ad6a674 into master Feb 1, 2021
@macfarlandian macfarlandian deleted the ian/296/demographics-refactor branch February 1, 2021 20:09
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.

3 participants