Skip to content

Instantly share code, notes, and snippets.

@paulsonnentag
Created March 4, 2024 08:07
Show Gist options
  • Save paulsonnentag/4343078a9f26b2cf7bbbb61569530edb to your computer and use it in GitHub Desktop.
Save paulsonnentag/4343078a9f26b2cf7bbbb61569530edb to your computer and use it in GitHub Desktop.
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