Refactor user storage and update
Rename accounts to users to be consistent with the new naming scheme where account only referes to the logged in user of the session and implement live updates of users via a user store which listens for updates from the event stream.
This commit is contained in:
parent
6336ccdb96
commit
3be7f8be05
24 changed files with 331 additions and 182 deletions
|
@ -260,7 +260,7 @@ function toShift(origin: Date, shorthand: string, idToAssigned: Map<number, numb
|
|||
};
|
||||
}
|
||||
|
||||
export function generateDemoSchedule(): ApiSchedule {
|
||||
function getDemoOrigin() {
|
||||
const origin = new Date();
|
||||
const utcOffset = 1;
|
||||
origin.setUTCDate(origin.getUTCDate() - origin.getUTCDay() + 1); // Go to Monday
|
||||
|
@ -268,10 +268,15 @@ export function generateDemoSchedule(): ApiSchedule {
|
|||
origin.setUTCMinutes(0);
|
||||
origin.setUTCSeconds(0);
|
||||
origin.setUTCMilliseconds(0);
|
||||
return origin;
|
||||
}
|
||||
|
||||
export function generateDemoSchedule(): ApiSchedule {
|
||||
const origin = getDemoOrigin();
|
||||
|
||||
const eventCounts = new Map<number, number>()
|
||||
const slotCounts = new Map<number, number>()
|
||||
const accounts = generateDemoAccounts();
|
||||
const accounts = generateDemoAccounts(origin);
|
||||
for (const account of accounts) {
|
||||
for (const id of account.interestedEventIds ?? []) {
|
||||
eventCounts.set(id, (eventCounts.get(id) ?? 0) + 1);
|
||||
|
@ -390,13 +395,14 @@ function random() {
|
|||
return (seed = (a * seed + c) % m | 0) / 2 ** 31;
|
||||
}
|
||||
|
||||
export function generateDemoAccounts(): ApiAccount[] {
|
||||
export function generateDemoAccounts(origin = getDemoOrigin()): ApiAccount[] {
|
||||
seed = 1;
|
||||
const accounts: ApiAccount[] = [];
|
||||
|
||||
for (const name of names) {
|
||||
accounts.push({
|
||||
id: accounts.length,
|
||||
updatedAt: toIso(toDate(origin, "d-1", "10:41")),
|
||||
name,
|
||||
type: (["regular", "crew", "crew", "crew", "admin"] as const)[Math.floor(random() ** 3 * 5)],
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue