Skip to content

Instantly share code, notes, and snippets.

@alan-andrade
Created May 13, 2015 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alan-andrade/f077a2e638763f53254f to your computer and use it in GitHub Desktop.
Save alan-andrade/f077a2e638763f53254f to your computer and use it in GitHub Desktop.
There are two pieces of information that the local provider and this method
are interested on and therefore the duplication.
1. User subscription status
2. User brain area of focus (from the personalization survery, the most relevant brain area)
This data is used to figure out which "scriptId" should be returned in the
resulting string.
What seems confusing, is the name of the method. It implies that "scriptId" is
a number and It turns out this is just the name of the scripted workout which
could be one of the following:
- balance
- free
- memory
- speed
- flexibility
- problemsolving
- attention
This list is basically a group formed by other two subgroups.
Group A: balance, free
Group B: lumos brain areas
`A + B`
Looking deeper in the method, we can see that `focusIdentifier` is compared
against `LLBrainAreaBalanced`.
> `LLBrainAreaBalanced` is not a brain area so I think we should change it to
avoid misunderstandings. Why would `user.brainAreaOfFocus` return a brainArea
out of the known range ?
If the comparison above fails, the `sharedBrainAreaList` is used by calling
`personalizationNameByIdentifier`. Ok, this tells me there's a relationship
between `user.brainAreaOfFocus` and `sharedBrainAreaList`, **but**
Why is this treated differently from the above ?!
That's because `user.brainAreaOfFocus` returns one of the following
possible results: `LLBrainAreaBalanced` + lumos brain areas by identifier name
> identifier name is the name that is used as key in the brain areas
configuration file and the format is like this: "brainArea_{name}" where
name could be any of the lumos brain areas.
Even when we use `sharedBrainAreaList` which must be the last source of truth
in regards the user training preference, could still fail and then we fallback
to the `kScriptFree`! __WHY!?__
> The reason (as far as I can tell) is because `sharedBrainAreaList` contains
mutant brain areas ! The group that was supposed to only contain the lumos
brain areas also contains the "Overall" alien.
As last observation, I'd like to know why the code would end up in this
last branch where the user is a __subscriber__ and `scriptId` is not balanced,
is not any of the possible lumos brain areas and we fallback to free. Isn't
that an impossible state? A subscriber with a free script ?
## Summary
`user.brainAreaOfFocus` is returning adhoc results for the scripted workouts
feature.
`sharedBrainAreaList` contains alien members [which I can see how it's used for
other purposes, but at least we should keep a clean and well defined list whenever
we call `personalizationNameByIdentifier`]
I don't know how this code could be refactored so that localProvider and
GameManager share it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment