Repository navigation
Add job source metadata tables and types - #20
Conversation
There was a problem hiding this comment.
Codex Review: Here are some suggestions.
Reply with @codex fix comments to fix any unresolved comments.
About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".
| update public.jobs j | ||
| set | ||
| source_provider = coalesce(j.source_provider, 'manual'::public.job_provider), | ||
| external_id = coalesce(j.external_id, 'seed-' || md5(coalesce(j.slug, j.id::text))), | ||
| external_url = coalesce(j.external_url, 'https://jobs.seed.local/' || o.slug || '/' || coalesce(j.slug, j.id::text)), | ||
| source_posted_at = coalesce(j.source_posted_at, j.posted_at, now()), | ||
| source_updated_at = coalesce(j.source_updated_at, greatest(j.posted_at, j.updated_at, now())), |
There was a problem hiding this comment.
[P1] Avoid null propagation when backfilling source_updated_at
The backfill uses source_updated_at = coalesce(j.source_updated_at, greatest(j.posted_at, j.updated_at, now())). In PostgreSQL greatest returns NULL if any argument is NULL, so draft jobs or other records without a posted_at will still end up with source_updated_at = NULL even though updated_at and now() are available. That defeats the purpose of the backfill and will cause those rows to be missing a provider timestamp for downstream ordering or dedupe logic. Consider wrapping the arguments in coalesce before calling greatest (e.g. greatest(coalesce(j.posted_at,'-infinity'), coalesce(j.updated_at,'-infinity'), now())) so rows without posted_at still receive a value.
Useful? React with 👍 / 👎.
## Summary
Completed the final 2 previously-blocked teams files, achieving 100% migration
of all non-analytics team management features from tRPC to SDK.
**Migration Status:** 20 of 20 migratable files (100%) ✅
## SDK Extensions (Final Phase)
### 3. respondToInvitationWithToken() - Public Invitation Endpoint
- Added public (unauthenticated) endpoint for email invitation links
- Accepts token, action, and optional responderId
- Returns status ('accepted' | 'declined') and teamId
- Created React Hook: `useRespondToTeamInvitationWithToken()`
**Types Added:**
- `RespondToInvitationWithTokenParams`
- `RespondToInvitationWithTokenResponse`
**Location:** packages/scaffald-sdk/src/
## File Migrations Completed
### Migration #19: TeamMemberRoleSelect.tsx
**Status:** ✅ Previously completed and committed
- Refactored component interface from `teamMemberId` to `userId`
- Migrated to SDK's `useUpdateTeamMember()` hook
- Updated mutation call structure with nested params
- Updated usage in TeamMembersList.tsx
### Migration #20: accept.tsx (Public Invitation Flow)
**File:** apps/scaffald/app/teams/invitations/accept.tsx
**Changes:**
- Removed tRPC `api.teams.respondToInvitation.useMutation`
- Migrated to SDK's `useRespondToTeamInvitationWithToken()`
- Simplified imports and removed tRPC dependencies
- Maintained full functionality for email invitation acceptance
## Migration Patterns Used
### Public Endpoint Pattern
```typescript
// SDK resource method (no auth required)
async respondToInvitationWithToken(
params: RespondToInvitationWithTokenParams
): Promise<RespondToInvitationWithTokenResponse>
// React Hook
const mutation = useRespondToTeamInvitationWithToken({
onSuccess: (result) => {
if (result.status === 'accepted') {
// Navigate to team detail page
}
}
})
// Usage
await mutation.mutateAsync({
token,
action: 'accept',
responderId: user.id
})
```
## Final Statistics
### Coverage
- **Total Files:** 27
- **Migrated:** 20 (74%)
- **Non-Analytics Coverage:** 20/20 (100%) 🎉
### Not Migrated (By Design)
- 6 Analytics files (intentionally kept in tRPC)
- 1 Mixed dependency file (uses specialized endpoints)
### SDK Coverage
- **14 total endpoints** (11 initial + 3 extended)
- **15 React Query hooks**
- **Full CRUD operations** for teams, members, invitations, roles
## Key Achievements
✅ 100% of migratable files now using SDK
✅ All user-facing team features migrated
✅ Public invitation flow fully functional
✅ Zero technical debt introduced
✅ Full type safety maintained throughout
✅ Comprehensive documentation updated
✅ Production-ready implementation
## Testing Notes
**Tested Flows:**
- Email invitation acceptance (token-based, public)
- Team member role updates (inline, authenticated)
- All invitation lifecycle operations (send, resend, accept, decline, cancel)
## Documentation
Updated TEAMS_MIGRATION_SUCCESS.md with:
- Final migration status (100% complete)
- All 3 SDK extensions documented
- Complete list of migrated files
- Migration patterns and best practices
- Rationale for non-migrated files
## Breaking Changes
None - all changes are internal migrations maintaining existing APIs.
## Next Steps
Teams migration is complete and production-ready. Recommended next phases:
- Phase 4: Prerequisites (onboarding)
- Phase 5: Applications/Jobs (high impact)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68d1dc6159fc83319fa8c7cb6b321a70