Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
--on-accent: #ffffff;
--star: #c48a00;
--danger: #b42318;
--live: #1a7f37;
--late: #bc4c00;
--stale: #cf222e;
--selection: #cfe0fa;
--series-1: #2a78d6;
--series-2: #eb6834;
Expand Down Expand Up @@ -58,6 +61,9 @@
--on-accent: #0d1117;
--star: #e3b341;
--danger: #ff8a80;
--live: #3fb950;
--late: #db6d28;
--stale: #f85149;
--selection: #1f3a5f;
--series-1: #3987e5;
--series-2: #d95926;
Expand Down
156 changes: 142 additions & 14 deletions src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,49 +1,177 @@
<script lang="ts">
import { onMount } from 'svelte';
import { lateness } from '#lib/freshness.ts';
import Updated from './Updated.svelte';

const { updated }: { updated?: number } = $props();

// judged in the browser, as the edge cache can hand out a page rendered hours ago
let now = $state<number>();
onMount(() => {
now = Date.now();
});
const behind = $derived(updated && now ? lateness(now - updated) : 'fresh');
</script>

<footer class="site-footer">
<div class="bar">
<div class="about">
<p>Unofficial, and not affiliated with GitHub. Stars come from GitHub's public API.</p>
<Updated at={updated} label="Rankings updated" />
</div>
<p class="status">
{#if updated}<span class="dot {behind}" aria-hidden="true"></span>{/if}
<Updated at={updated} label="Rankings updated" inline />
</p>
<nav aria-label="About this site">
<a href="/about">How it works</a>
<a href="/badge-builder">Badge builder</a>
<a href="/about#privacy">Privacy</a>
<a href="https://github.com/NotAFlightRisk/git-star-ranking">Source</a>
</nav>
<p class="credits">
Built by <a href="https://github.com/NotAFlightRisk" rel="external">@NotAFlightRisk</a>.
Licensed under MIT, ©&nbsp;<a href="https://peng.ly" rel="external">peng.ly</a> 2026.
<a class="source" href="https://github.com/NotAFlightRisk/git-star-ranking" rel="external">
View source on GitHub
</a>
</p>
<p class="disclaimer">
git-star-ranking.com is unofficial, and not affiliated with GitHub. All data comes from
GitHub's public API.
</p>
</div>
</footer>

<style>
.site-footer {
margin-block-start: auto;
border-block-start: 1px solid var(--border);
background: var(--surface-raised);
color: var(--text-muted);
font-size: var(--text-sm);

a {
color: inherit;

&:hover {
color: var(--accent);
}
}
}

.bar {
max-width: var(--page);
margin-inline: auto;
padding: var(--space-5) var(--space-4);
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: var(--space-3) var(--space-5);
padding: var(--space-4);
display: grid;
grid-template-columns: 1fr auto;
align-items: start;
gap: var(--space-1) var(--space-5);
}

.about {
display: grid;
gap: var(--space-1);
.credits,
.disclaimer {
grid-column: 1 / -1;
text-wrap: pretty;
}

.credits {
margin-block-start: var(--space-1);
}

.source {
white-space: nowrap;
}

.status {
color: var(--text);
}

.status :global(.updated) {
color: inherit;
}

nav {
justify-self: end;
color: var(--text);
display: flex;
gap: var(--space-4);
flex-wrap: wrap;
gap: var(--space-1) var(--space-4);

a {
text-decoration: none;

&:hover {
text-decoration: underline;
}
}
}

/* inline, so it stays beside the first word when the line wraps */
.dot {
position: relative;
display: inline-block;
vertical-align: middle;
margin-inline-end: var(--space-1);
inline-size: 0.5rem;
block-size: 0.5rem;
border-radius: 50%;
background: var(--live);

&::after {
content: '';
position: absolute;
inset: 0;
border-radius: inherit;
background: inherit;
animation: pulse 5s ease-out infinite;
}

&.late {
background: var(--late);
}

&.stale {
background: var(--stale);
}

/* only a healthy heartbeat pulses */
&:is(.late, .stale)::after {
animation: none;
}
}

@keyframes pulse {
from {
opacity: 0.7;
transform: scale(1);
}

30%,
to {
opacity: 0;
transform: scale(2.5);
}
}

@media (prefers-reduced-motion: reduce) {
.dot::after {
animation: none;
}
}

@media (max-width: 48rem) {
.bar {
grid-template-columns: 1fr;
row-gap: var(--space-2);
text-align: center;
}

nav {
justify-self: center;
justify-content: center;
}

/* centred lines look ragged unless they're roughly even */
.credits,
.disclaimer {
text-wrap: balance;
}
}
</style>
10 changes: 10 additions & 0 deletions src/lib/freshness.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const HOUR = 3_600_000;

/** Two six-hourly snapshots missed in a row, when the uptime check raises the alarm */
export const SNAPSHOT_LATE = 13 * HOUR;
// a whole day without one
const SNAPSHOT_STALE = 24 * HOUR;

/** How far behind the rankings are, going by how old the last snapshot is */
export const lateness = (age: number) =>
age > SNAPSHOT_STALE ? 'stale' : age > SNAPSHOT_LATE ? 'late' : 'fresh';
3 changes: 1 addition & 2 deletions src/lib/server/health.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { SNAPSHOT_LATE } from '../freshness.ts';
import { readMeta } from './boards.ts';
import { oldestDue } from './db.ts';
import { ALERT_AT, budget } from './usage.ts';

const HOUR = 3_600_000;
// snapshots land every six hours, so this is two in a row gone missing
const SNAPSHOT_LATE = 13 * HOUR;
// a day past due means the crawl isn't keeping up
const CRAWL_LATE = 24 * HOUR;

Expand Down
20 changes: 20 additions & 0 deletions tests/lib/freshness.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from 'vitest';
import { lateness } from '../../src/lib/freshness.ts';

const HOUR = 3_600_000;

describe('lateness', () => {
it('is fresh through a single missed snapshot', () => {
expect(lateness(0)).toBe('fresh');
expect(lateness(12 * HOUR)).toBe('fresh');
});

it('is late once two in a row have gone missing, same as the uptime check', () => {
expect(lateness(14 * HOUR)).toBe('late');
expect(lateness(23 * HOUR)).toBe('late');
});

it('is stale after a whole day without one', () => {
expect(lateness(25 * HOUR)).toBe('stale');
});
});
Loading