fix(web): shelf headings count through plural(), and the day-count test matches calendar days
release / go (push) Successful in 1m53s
release / web (push) Successful in 1m44s
release / govulncheck (push) Successful in 24s
release / integration (push) Successful in 5m6s
release / android (push) Successful in 5m21s
release / Build signed APK (push) Successful in 5m49s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 29s
release / Verify release artifacts (tag releases only) (push) Skipped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 16:13:57 -05:00
co-authored by Claude Opus 5.5
parent 5e7b8a7694
commit 16225f09f7
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ describe('refreshedLabel', () => {
test('yesterday and older', () => { test('yesterday and older', () => {
const now = new Date('2026-11-23T12:00:00'); const now = new Date('2026-11-23T12:00:00');
expect(refreshedLabel('2026-11-22T12:00:00', now)).toBe('Refreshed yesterday'); expect(refreshedLabel('2026-11-22T12:00:00', now)).toBe('Refreshed yesterday');
expect(refreshedLabel('2026-11-20T12:00:00', now)).toBe('Refreshed 4 days ago'); expect(refreshedLabel('2026-11-20T12:00:00', now)).toBe('Refreshed 3 days ago');
}); });
}); });
+3 -2
View File
@@ -1,6 +1,7 @@
// What a home shelf of playlist tiles shows: which album covers each tile // What a home shelf of playlist tiles shows: which album covers each tile
// gets, and the one line of facts the shelf's tiles share. // gets, and the one line of facts the shelf's tiles share.
import type { Playlist } from '#lib/api/types.js'; import type { Playlist } from '#lib/api/types.js';
import { plural } from '#lib/utils/plural.js';
// Each tile takes the first of its playlist's cover albums that no tile // Each tile takes the first of its playlist's cover albums that no tile
// before it on the shelf already shows, so a shelf never repeats a cover // before it on the shelf already shows, so a shelf never repeats a cover
@@ -48,11 +49,11 @@ export function shelfMeta(playlists: Playlist[], now: Date = new Date()): string
const lo = counts[0]; const lo = counts[0];
const hi = counts[counts.length - 1]; const hi = counts[counts.length - 1];
if (lo === hi) { if (lo === hi) {
parts.push(`${lo} ${lo === 1 ? 'song' : 'songs'} each`); parts.push(`${plural(lo, 'song', 'songs')} each`);
} else if (hi - lo <= hi * 0.1) { } else if (hi - lo <= hi * 0.1) {
// Close enough to read as one size: round the middle to a friendly 5. // Close enough to read as one size: round the middle to a friendly 5.
const mid = counts[Math.floor(counts.length / 2)]; const mid = counts[Math.floor(counts.length / 2)];
parts.push(`about ${Math.max(5, Math.round(mid / 5) * 5)} songs each`); parts.push(`about ${plural(Math.max(5, Math.round(mid / 5) * 5), 'song', 'songs')} each`);
} }
const labels = new Set(mixes.map((p) => refreshedLabel(p.created_at, now))); const labels = new Set(mixes.map((p) => refreshedLabel(p.created_at, now)));