Skip to content

Extract shared run logic to eliminate cron/manual duplication #15

@jluk

Description

@jluk

Problem

src/app/api/cron/run/route.ts and src/app/api/run/route.ts duplicate ~80 lines of identical logic: source fetching, dedup, Gemini analysis, findings insert, run status update. When one gets updated, the other drifts.

Goal

Extract a shared executeRun() function in src/lib/run-competitor.ts that both routes call. Each route only handles its own concerns (auth, request parsing, response format).

Scope

  • New src/lib/run-competitor.ts with shared run logic
  • Simplify both API routes to thin wrappers
  • Update tests accordingly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions