Created
March 4, 2024 08:07
-
-
Save paulsonnentag/4343078a9f26b2cf7bbbb61569530edb to your computer and use it in GitHub Desktop.
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
const AACHEN = { lat: 50.7753, long: 6.0839 }; | |
reaction( | |
() => Day.getAll(), | |
(days) => { | |
days.forEach(async (day) => { | |
const forecast = await getWeatherForecast(AACHEN, day.start, day.end); | |
if (!forecast) { | |
return; | |
} | |
Sticker.create({ | |
target: day, | |
label: `${forecast.weatherEmoji} ${Math.round( | |
forecast.minTemperature | |
)}° - ${Math.round(forecast.maxTemperature)}°`, | |
}); | |
}); | |
} | |
); | |
reaction( | |
() => Day.getAll(), | |
async (days) => { | |
let minStartDate = days[0].start; | |
let maxEndDate = days[0].end; | |
days.forEach((day) => { | |
if (day.start < minStartDate) { | |
minStartDate = day.start; | |
} | |
if (day.end > maxEndDate) { | |
maxEndDate = day.end; | |
} | |
}); | |
const events = await getEventsBetween(minStartDate, maxEndDate); | |
console.log(events); | |
} | |
); | |
reaction( | |
() => Event.getAll(), | |
async (events) => { | |
console.log(events); | |
events.forEach(async (event) => { | |
if (!event.location) { | |
return; | |
} | |
const forecast = await getWeatherForecast( | |
event.location, | |
event.start, | |
event.end | |
); | |
if (!forecast) { | |
return; | |
} | |
Sticker.create({ | |
target: event, | |
label: `${forecast.weatherEmoji} ${Math.round( | |
forecast.meanTemperature | |
)}° (${event.location.title})`, | |
}); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment