Refactor: extract service layers from API routes + consistent UI#12
Merged
Conversation
…/schedule/ Move schedule-manager.ts and schedule-validation.ts into src/lib/schedule/, extract business logic from API controllers into a new service.ts, and slim controllers down to thin HTTP adapters (matching the chat/ folder pattern). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move business logic from teams API controllers into a new service module, matching the schedule/ folder pattern. Adds 404 check for team updates and typed errors (TeamNotFoundError, TeamDuplicateError). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover DB dedup (keeps first/latest row per login), case-insensitive query filtering by login and github_name, limit truncation, and GitHub source path (member mapping, query filtering, 20-result cap). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move DB query, dedup, filtering, and GitHub member lookup out of the API controller into listDevelopers() and listDevelopersFromGitHub() service functions. Controller is now a thin adapter. Barrel export via index.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
18 tests covering listReports, createReport, getReport, deleteReport, getReportProgress, stopReport, and resumeReport — including typed error cases (ReportNotFoundError, ReportNotRunningError, ReportAlreadyCompletedError). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Creates src/lib/report/service.ts with typed errors (ReportNotFoundError, ReportNotRunningError, ReportAlreadyCompletedError) and all business logic extracted from 5 controller files. Controllers are now thin adapters that parse params, call service functions, and map typed errors to HTTP status codes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests for dedupCommitsBySha and aggregateWeekly covering deduplication, Monday-aligned weekly grouping, complexity averaging, AI percent calculation, dev tracking, type grouping, and null date skipping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extracts dedupCommitsBySha and aggregateWeekly into src/lib/report/timeline.ts to eliminate duplicated weekly bucketing logic across report controllers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests for getReportCommits and getOrgReport covering happy paths, ReportNotFoundError, JSON column parsing, trackDevs timeline, and SHA dedup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract business logic from commits and org route controllers into src/lib/report/commits.ts and src/lib/report/org.ts, using the shared dedupCommitsBySha/aggregateWeekly helpers from timeline.ts. Controllers become thin adapters. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add unit tests for getDevReport and getDevSummary covering happy paths, error cases (ReportNotFoundError, DeveloperNotFoundError), JSON column parsing, timeline shape (no activeDevs), dedup, caching, and LLM call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract business logic from the 157-line dev controller into src/lib/report/dev.ts (getDevReport, DeveloperNotFoundError) and from the 192-line summary controller into src/lib/report/summary.ts (getDevSummary). Slim both controllers down to error-dispatch wrappers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace dog mascot icon with hexagonal crystal design. Remove duplicate icon from public/ that caused a Next.js conflicting file error (500). Drop redundant icons metadata from layout since Next.js auto-discovers app/icon.svg. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use consistent red overlay confirmation UI for schedule and team deletion, matching the existing report deletion pattern. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The most important change
New app icon:
Just kidding. But it does look good.
Summary
src/lib/modules — separates business logic from HTTP concernssrc/lib/report/timeline.ts) to DRY up repeated date-bucketing logicschedule-manager.tsandschedule-validation.tsintosrc/lib/schedule/public/icon.svgthat caused a Next.js 500 error, replace with hexagonal gem designModules extracted
src/lib/teams/src/lib/developers/src/lib/orgs/src/lib/llm-config/src/lib/report/service.tssrc/lib/report/*.tssrc/lib/report-highlights/src/lib/schedule/Consistent delete entity confirmation UI (the same as on report delete dialog)
Test plan
npm run dev)🤖 Generated with Claude Code