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.";
}
}