Last active
May 6, 2020 10:41
-
-
Save edgerunner/c3149add0f3dac1e26a6b1ae06d86333 to your computer and use it in GitHub Desktop.
Cow &
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.unique = function () { | |
return [...new Set(this)] | |
} | |
function render(model){ | |
return ( | |
<p> Tags: | |
{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