From 87dd67767a6ea80bd0231a4f3488c21bdc595db5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 16:45:23 +0000 Subject: [PATCH] Revert "display total skills count on /skills page (#76)" This reverts commit 89933951f5fd591bf9e4b23cb76ac51f9c62c0b0. --- CHANGELOG.md | 1 - convex/crons.ts | 7 --- convex/schema.ts | 7 --- convex/skills.ts | 12 ------ convex/statsMaintenance.ts | 43 ------------------- src/__tests__/skills-index-load-more.test.tsx | 4 -- src/__tests__/skills-index.test.tsx | 4 -- src/routes/skills/index.tsx | 6 --- 8 files changed, 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b943a94..26abdfd92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,6 @@ - Skills: keep global sorting across pagination on `/skills` (thanks @CodeBBakGoSu, #98). - Skills: allow updating skill description/summary from frontmatter on subsequent publishes (#312) (thanks @ianalloway). - Skills/Web: prevent filtered pagination dead-ends and loading-state flicker on `/skills`; move highlighted browse filtering into server list query (#339) (thanks @Marvae). -- Web: align `/skills` total count with public visibility and format header count (thanks @rknoche6, #76). ## 0.6.1 - 2026-02-13 diff --git a/convex/crons.ts b/convex/crons.ts index f9f8743f6..ed22aece7 100644 --- a/convex/crons.ts +++ b/convex/crons.ts @@ -31,13 +31,6 @@ crons.interval( {}, ) -crons.interval( - 'global-stats-update', - { minutes: 60 }, - internal.statsMaintenance.updateGlobalStatsInternal, - {}, -) - crons.interval('vt-pending-scans', { minutes: 5 }, internal.vt.pollPendingScans, { batchSize: 100 }) crons.interval('vt-cache-backfill', { minutes: 30 }, internal.vt.backfillActiveSkillsVTCache, { diff --git a/convex/schema.ts b/convex/schema.ts index a8993da53..d86de7286 100644 --- a/convex/schema.ts +++ b/convex/schema.ts @@ -342,12 +342,6 @@ const skillStatBackfillState = defineTable({ updatedAt: v.number(), }).index('by_key', ['key']) -const globalStats = defineTable({ - key: v.string(), - activeSkillsCount: v.number(), - updatedAt: v.number(), -}).index('by_key', ['key']) - const skillStatEvents = defineTable({ skillId: v.id('skills'), kind: v.union( @@ -580,7 +574,6 @@ export default defineSchema({ skillDailyStats, skillLeaderboards, skillStatBackfillState, - globalStats, skillStatEvents, skillStatUpdateCursors, comments, diff --git a/convex/skills.ts b/convex/skills.ts index 83964c70b..0a2f95e42 100644 --- a/convex/skills.ts +++ b/convex/skills.ts @@ -1632,18 +1632,6 @@ function isCursorParseError(error: unknown) { return false } -export const countPublicSkills = query({ - args: {}, - handler: async (ctx) => { - const stats = await ctx.db - .query('globalStats') - .withIndex('by_key', (q) => q.eq('key', 'default')) - .unique() - // Null means global stats haven't been initialized yet. - return stats?.activeSkillsCount ?? null - }, -}) - function sortToIndex( sort: 'downloads' | 'stars' | 'installsCurrent' | 'installsAllTime', ): diff --git a/convex/statsMaintenance.ts b/convex/statsMaintenance.ts index 1cca80bda..b80e4012b 100644 --- a/convex/statsMaintenance.ts +++ b/convex/statsMaintenance.ts @@ -3,14 +3,12 @@ import { internal } from './_generated/api' import type { Doc } from './_generated/dataModel' import type { ActionCtx } from './_generated/server' import { internalAction, internalMutation, internalQuery } from './_generated/server' -import { toPublicSkill } from './lib/public' const DEFAULT_BATCH_SIZE = 200 const MAX_BATCH_SIZE = 1000 const DEFAULT_MAX_BATCHES = 5 const MAX_MAX_BATCHES = 50 const BACKFILL_STATE_KEY = 'default' -const GLOBAL_STATS_PAGE_SIZE = 500 export const backfillSkillStatFieldsInternal = internalMutation({ args: { @@ -301,44 +299,3 @@ export const runReconcileSkillStarCountsInternal = internalAction({ function clampInt(value: number, min: number, max: number) { return Math.min(Math.max(value, min), max) } - -export const updateGlobalStatsInternal = internalMutation({ - args: {}, - handler: async (ctx) => { - let count = 0 - let cursor: string | null = null - - while (true) { - const { page, isDone, continueCursor } = await ctx.db - .query('skills') - .withIndex('by_active_updated', (q) => q.eq('softDeletedAt', undefined)) - .order('asc') - .paginate({ cursor, numItems: GLOBAL_STATS_PAGE_SIZE }) - - for (const skill of page) { - if (toPublicSkill(skill)) { - count += 1 - } - } - - if (isDone) break - cursor = continueCursor - } - - const now = Date.now() - const existing = await ctx.db - .query('globalStats') - .withIndex('by_key', (q) => q.eq('key', 'default')) - .unique() - - if (existing) { - await ctx.db.patch(existing._id, { activeSkillsCount: count, updatedAt: now }) - } else { - await ctx.db.insert('globalStats', { - key: 'default', - activeSkillsCount: count, - updatedAt: now, - }) - } - }, -}) diff --git a/src/__tests__/skills-index-load-more.test.tsx b/src/__tests__/skills-index-load-more.test.tsx index 38f574652..0de5562bb 100644 --- a/src/__tests__/skills-index-load-more.test.tsx +++ b/src/__tests__/skills-index-load-more.test.tsx @@ -7,7 +7,6 @@ import { SkillsIndex } from '../routes/skills/index' const navigateMock = vi.fn() const useActionMock = vi.fn() -const useQueryMock = vi.fn() const usePaginatedQueryMock = vi.fn() let searchMock: Record = {} @@ -22,7 +21,6 @@ vi.mock('@tanstack/react-router', () => ({ vi.mock('convex/react', () => ({ useAction: (...args: unknown[]) => useActionMock(...args), - useQuery: (...args: unknown[]) => useQueryMock(...args), usePaginatedQuery: (...args: unknown[]) => usePaginatedQueryMock(...args), })) @@ -30,11 +28,9 @@ describe('SkillsIndex load-more observer', () => { beforeEach(() => { usePaginatedQueryMock.mockReset() useActionMock.mockReset() - useQueryMock.mockReset() navigateMock.mockReset() searchMock = {} useActionMock.mockReturnValue(() => Promise.resolve([])) - useQueryMock.mockReturnValue(null) }) afterEach(() => { diff --git a/src/__tests__/skills-index.test.tsx b/src/__tests__/skills-index.test.tsx index 83be7d468..0f62d46dd 100644 --- a/src/__tests__/skills-index.test.tsx +++ b/src/__tests__/skills-index.test.tsx @@ -7,7 +7,6 @@ import { SkillsIndex } from '../routes/skills/index' const navigateMock = vi.fn() const useActionMock = vi.fn() -const useQueryMock = vi.fn() const usePaginatedQueryMock = vi.fn() let searchMock: Record = {} @@ -22,7 +21,6 @@ vi.mock('@tanstack/react-router', () => ({ vi.mock('convex/react', () => ({ useAction: (...args: unknown[]) => useActionMock(...args), - useQuery: (...args: unknown[]) => useQueryMock(...args), usePaginatedQuery: (...args: unknown[]) => usePaginatedQueryMock(...args), })) @@ -30,11 +28,9 @@ describe('SkillsIndex', () => { beforeEach(() => { usePaginatedQueryMock.mockReset() useActionMock.mockReset() - useQueryMock.mockReset() navigateMock.mockReset() searchMock = {} useActionMock.mockReturnValue(() => Promise.resolve([])) - useQueryMock.mockReturnValue(null) // Default: return empty results with Exhausted status usePaginatedQueryMock.mockReturnValue({ results: [], diff --git a/src/routes/skills/index.tsx b/src/routes/skills/index.tsx index 9abb0d6fc..85129dab6 100644 --- a/src/routes/skills/index.tsx +++ b/src/routes/skills/index.tsx @@ -1,7 +1,5 @@ import { createFileRoute, redirect } from '@tanstack/react-router' -import { useQuery } from 'convex/react' import { useRef } from 'react' -import { api } from '../../../convex/_generated/api' import { parseSort } from './-params' import { SkillsResults } from './-SkillsResults' import { SkillsToolbar } from './-SkillsToolbar' @@ -51,9 +49,6 @@ export function SkillsIndex() { const navigate = Route.useNavigate() const search = Route.useSearch() const searchInputRef = useRef(null) - const totalSkills = useQuery(api.skills.countPublicSkills) - const totalSkillsText = - typeof totalSkills === 'number' ? totalSkills.toLocaleString('en-US') : null const model = useSkillsBrowseModel({ navigate, @@ -66,7 +61,6 @@ export function SkillsIndex() {

Skills - {totalSkillsText && {` (${totalSkillsText})`}}

{model.isLoadingSkills