import { getFlowLevel } from "https://esm.town/v/judson/MinnehahaFlowLevel";
import { email } from "https://esm.town/v/std/email?v=9";
export async function flowLevels(interval: Interval) {
const data = await getFlowLevel();
let goodConditions = false;
if (
data.graysBayDamCurrentValue.value >= 75 && data.graysBayDamCurrentValue.value <= 150
&& data.hiawathaCurrentValue.value >= 75 && data.hiawathaCurrentValue.value <= 150
) {
goodConditions = true;
}
if (!interval.lastRunAt) {
email({
text: `You will now get updates if Minnehaha Creek has good conditions for paddling.`,
subject: `Minnehaha Creek alerts set up!`,
});
}
if (goodConditions) {
email({
text: `Gray's Bay CFS: ${data.graysBayDamCurrentValue.value}, Hiawatha: ${data.hiawathaCurrentValue.value}`,
subject: `Minnehaha Creek Flow levels are good`,
});
}
}