Track which account is interested in which events
Store a list of ids of events and slots that accounts have marked as being interested in, and show aggeregate counts in the schedule.
This commit is contained in:
parent
ca51c07065
commit
db9a12250e
5 changed files with 137 additions and 0 deletions
|
@ -175,5 +175,40 @@ export function generateDemoAccounts(): Account[] {
|
|||
type: (["regular", "crew", "admin"] as const)[Math.floor(random() ** 5 * 3)],
|
||||
});
|
||||
}
|
||||
|
||||
// These have a much higher probability of being in someone's interested list.
|
||||
const desiredEvent = ["opening", "closing", "fursuit-games"];
|
||||
|
||||
for (const account of accounts) {
|
||||
const interestedIds: string[] = [];
|
||||
for (const id of desiredEvent) {
|
||||
if (random() < 0.5) {
|
||||
interestedIds.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
const eventsToAdd = Math.floor(random() * 10);
|
||||
while (interestedIds.length < eventsToAdd) {
|
||||
const event = events[Math.floor(random() * events.length)];
|
||||
const eventId = toId(event.name);
|
||||
if (interestedIds.some(id => id.replace(/-\d+$/, "") === eventId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event.slots.length === 1 || random() < 0.8) {
|
||||
interestedIds.push(toId(event.name))
|
||||
} else {
|
||||
for (const index of event.slots.map((_, index) => index)) {
|
||||
if (random() < 0.5) {
|
||||
interestedIds.push(toId(`${toId(event.name)}-${index}`));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (interestedIds.length) {
|
||||
account.interestedIds = interestedIds;
|
||||
}
|
||||
}
|
||||
return accounts;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue