Attempted to add new model, but now everything is broken

This commit is contained in:
Ozzie Gooen 2020-02-10 23:32:44 +00:00
parent a19c970b89
commit 641c3aadde
2 changed files with 60 additions and 1 deletions

View File

@ -0,0 +1,59 @@
module Model = {
let make = (dateTime: MomentRe.Moment.t, currentDateTime: MomentRe.Moment.t) => {
let yearDiff = MomentRe.diff(dateTime, currentDateTime, `days) /. 365.;
Prop.Value.Probability((100. -. yearDiff) /. 100.);
};
};
module Interface = {
let dayKey = "Day";
let run = (p: Prop.Combo.t) => {
switch (Prop.Combo.InputValues.toValueArray(p)) {
| [|Some(DateTime(intendedYear)), Some(DateTime(currentYear))|] =>
Some(Model.make(intendedYear, currentYear))
| _ => None
};
};
let model: Prop.Model.t =
Prop.{
name: "Global Catastrophe",
description: "The chances of catastrophe per year in the future.",
version: "1.0.0",
author: "Ozzie Gooen",
inputTypes: [|
TypeWithMetadata.make(
~name=dayKey,
~type_=
DateTime({
default:
Some(
MomentRe.Moment.add(
~duration=MomentRe.duration(5., `years),
MomentRe.momentNow(),
),
),
min:
Some(
MomentRe.Moment.subtract(
~duration=MomentRe.duration(20., `years),
MomentRe.momentNow(),
),
),
max:
Some(
MomentRe.Moment.add(
~duration=MomentRe.duration(20., `years),
MomentRe.momentNow(),
),
),
}),
(),
),
TypeWithMetadata.currentYear,
|],
outputTypes: [||],
run,
};
};