Skip to content

feat(api): DB-backed /users/stats and /tasks/stats#31

Open
kuyacarlo wants to merge 1 commit into
feat/api-surveysfrom
feat/api-db-stats
Open

feat(api): DB-backed /users/stats and /tasks/stats#31
kuyacarlo wants to merge 1 commit into
feat/api-surveysfrom
feat/api-db-stats

Conversation

@kuyacarlo

Copy link
Copy Markdown
Contributor

Stacked on #30.

Summary

  • GET /users/stats and GET /tasks/stats/:employeeId always computed from fixtures, so in DB mode they disagreed with the list endpoints they summarize. They now hydrate the @worksight/common lookup helpers from Postgres rows — same aggregation math, live data.
  • Fixes a latent bug in AssignmentLookup.getStats: it hardcoded the fixture Activities import even when the lookup was constructed with custom entries. The activity set is now an optional parameter defaulting to the fixtures, so web callers are unaffected (@worksight/web type-check verified).

Test plan

  • pnpm --filter @worksight/api type-check / lint / test — 19 green
  • pnpm --filter @worksight/web type-check — green (signature change is backwards compatible)
  • Against the Neon pooler: /users/stats reports 15 employees by role/department; /tasks/stats/E001-uuid reports 4 tasks, 50% completion, 6 activities

Made with Cursor

Both stats endpoints always echoed the fixtures, so in DB mode they
disagreed with the list endpoints they summarize. Hydrate the common
lookup helpers from repository rows instead — same math, live data.
AssignmentLookup.getStats previously hardcoded the fixture Activities
import even when constructed with custom entries; it now takes the
activity set as an optional parameter (defaulting to fixtures, so
existing web callers are unaffected).

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worksight Ready Ready Preview, Comment Jul 25, 2026 6:58pm
worksight-api Ready Ready Preview, Comment Jul 25, 2026 6:58pm
worksight-docs Ready Ready Preview, Comment Jul 25, 2026 6:58pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant