Skip to content

Instantly share code, notes, and snippets.

@edgerunner
Last active May 6, 2020 10:41
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 edgerunner/c3149add0f3dac1e26a6b1ae06d86333 to your computer and use it in GitHub Desktop.
Save edgerunner/c3149add0f3dac1e26a6b1ae06d86333 to your computer and use it in GitHub Desktop.
Cow &
Cow &
Tracking
Untracked
first-session-started -> Pending
Pending
session-activated -> Tracked
Tracked&
Temperature
Normal
fever-detected -> Fever
hypothermia-detected -> Hypothermia
Fever
normal-temperature-detected -> Normal
Hypothermia
normal-temperature-detected -> Normal
Reproduction
# Not reproductive yet
Calf
timer - 1y from birth -> Reproductive
Reproductive
Pre-estrus
timer 10d -> Estrus
Estrus
timer
Post-estrus
Inseminated
Pregnant
Post-partum
Lactation
Infertile
Array.prototype.unique = function () {
return [...new Set(this)]
}
function render(model){
return (
<p> Tags:&nbsp;
{model.active_states
.flatMap(parents)
.unique()
.flatMap(s => tags(s.name))
.filter(t => t)
.join(" | ")
}
</p>
);
}
function parents(state) {
return state.parent ? [ state, ...parents(state.parent) ] : [ state ]
}
// tags are not states. tags are just outputs of states.
function tags(state) {
return {
Pending: ["pending"],
Tracked: ["tracked"],
Pregnant: ["pregnant"],
Due: ["due"],
Fever: ["fever"],
Hypothermia: ["hypothermia"],
"Post-partum": ["post-partum"],
Calving: ["calving"]
}[state]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment