Skip to content

feat: include task owner email in tasks response (#418)#422

Merged
arpitgupta1214 merged 1 commit intomainfrom
test
Apr 10, 2026
Merged

feat: include task owner email in tasks response (#418)#422
arpitgupta1214 merged 1 commit intomainfrom
test

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 10, 2026

Summary by cubic

Tasks API now returns an owner_email for each task. Enrichment is now batched via enrichTasks to reduce Trigger.dev calls and simplify the handler.

  • New Features

    • Adds owner_email from account_emails for each task.
    • Keeps recent_runs and upcoming from Trigger.dev.
  • Refactors

    • Replaced enrichTaskWithTriggerInfo with batched enrichTasks.
    • Updated getTasksHandler to use enrichTasks.
    • Added tests for enrichTasks and getTasksHandler; removed the old single-task enrichment test.

Written for commit fe78298. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Improved task processing efficiency through optimized enrichment operations.

Co-authored-by: Sweets Sweetman <sweetmantech@gmail.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 10, 2026

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

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Apr 10, 2026 2:06am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f3421cf2-0d66-4daa-9b78-6cc516c3a717

📥 Commits

Reviewing files that changed from the base of the PR and between d673a22 and fe78298.

⛔ Files ignored due to path filters (3)
  • lib/tasks/__tests__/enrichTaskWithTriggerInfo.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/tasks/__tests__/enrichTasks.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/tasks/__tests__/getTasksHandler.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (3)
  • lib/tasks/enrichTaskWithTriggerInfo.ts
  • lib/tasks/enrichTasks.ts
  • lib/tasks/getTasksHandler.ts

📝 Walkthrough

Walkthrough

The pull request refactors the task enrichment pipeline from a per-task async operation to a bulk operation. The enrichTaskWithTriggerInfo module is removed and replaced with enrichTasks, which processes all tasks simultaneously while adding parallel account-email lookup. The task handler is updated to invoke the new bulk function instead of mapping over individual tasks.

Changes

Cohort / File(s) Summary
Task Enrichment Refactor
lib/tasks/enrichTaskWithTriggerInfo.ts
Removed legacy per-task enrichment module (49 lines) that fetched Trigger.dev run data and extracted upcoming payloads individually.
Bulk Enrichment Module
lib/tasks/enrichTasks.ts
Added new bulk enrichment function (86 lines) that processes all tasks concurrently, fetches trigger runs and owner emails in parallel, and returns enriched tasks with recent_runs, upcoming, and owner_email fields.
Task Handler Update
lib/tasks/getTasksHandler.ts
Updated import and invocation to use bulk enrichTasks instead of mapping enrichTaskWithTriggerInfo per task (2 lines changed).

Sequence Diagram(s)

sequenceDiagram
    participant Handler as getTasksHandler
    participant Enricher as enrichTasks
    participant TriggerAPI as fetchTriggerRuns
    participant DetailAPI as retrieveTaskRun
    participant Database as selectAccountEmails
    participant Output as Result

    Handler->>Enricher: enrichTasks(tasks[])
    par Parallel Processing
        Enricher->>TriggerAPI: fetchTriggerRuns (per task)
        Enricher->>Database: selectAccountEmails (all unique IDs)
    and TriggerAPI-->>Enricher: recent runs[]
    and Database-->>Enricher: account→email map
    end
    
    par Per Task Payload Extraction
        Enricher->>DetailAPI: retrieveTaskRun (latest run)
        DetailAPI-->>Enricher: full run data
        Enricher->>Enricher: extract payload.upcoming
    end
    
    Enricher->>Output: EnrichedTask[] (with owner_email)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested reviewers

  • sweetmantech

Poem

✨ From one-by-one to all at once so grand,
Tasks now enrich with parallel command—
Emails fetch swift while runs align,
Bulk operations make the pipeline shine! 📦

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arpitgupta1214 arpitgupta1214 merged commit 1bba6c3 into main Apr 10, 2026
5 of 7 checks passed
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