The first SonarQube Cloud scan reported 57 issues. 45 are fixed in code, the 11 on the saved itch.io test pages leave the scan via .sonarcloud.properties, and css:S8776 (Tailwind's @utility nesting) is a false positive to mark on SonarQube Cloud. Worker: trailing slashes and the gate cookie's padding are trimmed by trimEnd() instead of /\/+$/ (quadratic on the public 404 path); the feed and collection parsers lose their backtracking regexes; compareCodeUnits keeps the code-unit sorts (the rule's localeCompare is locale-dependent); Number.*, DEFAULT_SIZES, crypto.randomUUID; i18n-edit.mjs reads stdin. Pipeline: the NSFW notices are one selector list, either class (the rule's ".a.b" would need both), each tested; plain if-guards; update_info.main returns None; no plain-http adapter; [[ ]] in cf_build_status.sh. Supply chain: requirements*.txt are hash-locked pip-tools compiles of requirements*.in (on Python 3.14, which Dependabot reads from the header), installed with --require-hashes --only-binary :all: in block scalars; npm ci --ignore-scripts in CI and the release builds (verified by manual release runs on all platforms); npm run cf:check. Release 4.4.2: also ships the toolchain upgrade (#149, #154) and Dependabot #141-#148, #150, #152, #153. CLAUDE.md gotchas 40 and 41. [skip-discuss] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
/**
|
|
* Batches the maintainer queued (Add, Queue approvals, Restore), kept in this
|
|
* browser so their ingest can be followed after a reload: the Add page asks
|
|
* /api/admin/track how each game ended.
|
|
*/
|
|
import { create } from 'zustand'
|
|
import { persist } from 'zustand/middleware'
|
|
import type { TrackItem } from './api'
|
|
|
|
export interface TrackedBatch {
|
|
id: string
|
|
label: string
|
|
/** When it was queued (server time): only outcomes after it count. */
|
|
at: string
|
|
urls: string[]
|
|
}
|
|
|
|
const MAX_BATCHES = 20
|
|
const MAX_URLS = 10_000
|
|
|
|
/** Newest first, at most 20 batches and 10,000 URLs in all. */
|
|
export function capBatches(batches: TrackedBatch[]): TrackedBatch[] {
|
|
const out: TrackedBatch[] = []
|
|
let urls = 0
|
|
for (const b of batches) {
|
|
if (out.length >= MAX_BATCHES || urls + b.urls.length > MAX_URLS) break
|
|
out.push(b)
|
|
urls += b.urls.length
|
|
}
|
|
return out
|
|
}
|
|
|
|
interface TrackingState {
|
|
batches: TrackedBatch[]
|
|
track: (label: string, at: string, urls: string[]) => void
|
|
forget: (id: string) => void
|
|
}
|
|
|
|
export const useTracking = create<TrackingState>()(
|
|
persist(
|
|
(set) => ({
|
|
batches: [],
|
|
track: (label, at, urls) =>
|
|
set((s) =>
|
|
urls.length === 0
|
|
? s
|
|
: { batches: capBatches([{ id: `${at}-${crypto.randomUUID().slice(0, 8)}`, label, at, urls }, ...s.batches]) },
|
|
),
|
|
forget: (id) => set((s) => ({ batches: s.batches.filter((b) => b.id !== id) })),
|
|
}),
|
|
{ name: 'admin.batches' },
|
|
),
|
|
)
|
|
|
|
export interface TrackSummary {
|
|
added: number
|
|
waiting: number
|
|
dropped: number
|
|
unknown: number
|
|
}
|
|
|
|
export function summarize(items: TrackItem[]): TrackSummary {
|
|
const out: TrackSummary = { added: 0, waiting: 0, dropped: 0, unknown: 0 }
|
|
for (const i of items) out[i.state] += 1
|
|
return out
|
|
}
|