Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coalesce start and end dates of drafts with the student_ranks history #12

Open
BastiDood opened this issue Jul 15, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@BastiDood
Copy link
Owner

Currently, we display the log entries events in the following pattern:

{#if endDate !== null}
    <li>{endDate}</li>
{/if}
{#each events as event}
    <li>{event}</li>
{/each}
<li>{startDate}</li>

{#if end !== null}
{@const { endIsoString, endDateTime } = end}
<li class="mb-10 ms-6">
<span
class="bg-primary-300-600-token ring-primary-900-50-token absolute -start-3 flex size-6 items-center justify-center rounded-full ring-2"
><Icon src={CalendarDays} class="size-4" theme="micro" /></span
>
<h4 class="h4 mb-2"><time datetime={endIsoString}>{endDateTime}</time></h4>
<ol class="list">
<li class="card variant-ghost-success px-3 py-1.5">
<span class="flex-auto">Draft &num;{did} was concluded.</span>
</li>
</ol>
</li>
{/if}

{#each entries as [unix, events] (unix)}
{@const date = fromUnixTime(unix)}
{@const heading = format(date, 'PPPpp')}
<li class="mb-10 ms-6">
<span
class="bg-primary-300-600-token ring-primary-900-50-token absolute -start-3 flex size-6 items-center justify-center rounded-full ring-2"
><Icon src={CalendarDays} class="size-4" theme="micro" /></span
>
<h4 class="h4 mb-2"><time datetime={date.toISOString()}>{heading}</time></h4>
<ol class="list">
{#each events as { is_system, lab_id, round }}
{#if round !== null}
{@const ordinal = round + getOrdinalSuffix(round)}
{#if is_system}
<li class="card variant-soft-surface px-3 py-1.5">
<Icon src={Cog} class="size-4" theme="micro" />
<span class="flex-auto"
>The system has skipped the <strong class="uppercase">{lab_id}</strong> for the {ordinal}
round due to insufficient quota and/or zero demand.</span
>
</li>
{:else}
<li class="card variant-ghost-secondary px-3 py-1.5">
<Icon src={UserGroup} class="size-4" theme="micro" />
<span class="flex-auto"
>The <strong class="uppercase">{lab_id}</strong> has selected their {ordinal} batch
of draftees.</span
>
</li>
{/if}
{:else if is_system}
<li class="card variant-ghost-error px-3 py-1.5">
<Icon src={ExclamationTriangle} class="size-4" theme="micro" />
<span class="flex-auto"
>A system-automated event for the <strong class="uppercase">{lab_id}</strong>
occurred during a lottery. This should be impossible. Kindly
<a href="https://github.com/BastiDood/drap/issues/new" class="anchor"
>file an issue</a
> and report this bug there.</span
>
</li>
{:else}
<li class="card variant-ghost-tertiary px-3 py-1.5">
<Icon src={ArrowPath} class="size-4" theme="micro" />
<span class="flex-auto"
>The <strong class="uppercase">{lab_id}</strong> has obtained a batch of draftees from
the lottery round.</span
>
</li>
{/if}
{/each}
</ol>
</li>
{/each}

<li class="mb-10 ms-6">
<span
class="bg-primary-300-600-token ring-primary-900-50-token absolute -start-3 flex size-6 items-center justify-center rounded-full ring-2"
><Icon src={CalendarDays} class="size-4" theme="micro" /></span
>
<h4 class="h4 mb-2"><time datetime={startIsoString}>{startDateTime}</time></h4>
<ol class="list">
<li class="card variant-ghost-success px-3 py-1.5">
<span class="flex-auto">Draft &num;{did} was created.</span>
</li>
</ol>
</li>

This setup unfortunately sections off startDate and endDate from the events history. If endDate happens to be the same as the latest event in events, it would not be coalesced; it would be its own entry in the timeline. The solution is to merge the events under a single discriminated union, where the startDate and the endDate variants sandwich the internal events.

@BastiDood BastiDood added the bug Something isn't working label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant