1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { addPersonCount } from "https://esm.town/v/fgeierst/addPersonCount";
import { getMunichSwimCapacit } from "https://esm.town/v/fgeierst/getMunichSwimCapacit";
import { isGermanBusinessHours } from "https://esm.town/v/fgeierst/isGermanBusinessHours";
export async function pushToArchive() {
if (isGermanBusinessHours()) {
const organizationUnitIds = await getMunichSwimCapacit();
const results = await Promise.all(
organizationUnitIds.map(async (item) => {
const result = await addPersonCount(
item.id,
item.personCount,
item.maxPersonCount,
);
return result;
}),
);
return {
message: `Added ${results.length} rows to the database.`,
results,
};
}
else {
return "Cancled because not in business hours.";
}
}