Skip to content

Commit 047c464

Browse files
authored
feat: async opportunity parsing (#3443)
1 parent 7c23509 commit 047c464

12 files changed

Lines changed: 1202 additions & 318 deletions

File tree

.infra/common.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ export const workers: Worker[] = [
464464
topic: 'api.v1.opportunity-feedback-submitted',
465465
subscription: 'api.parse-opportunity-feedback',
466466
},
467+
{
468+
topic: 'api.v1.opportunity-parse',
469+
subscription: 'api.opportunity-parse',
470+
},
467471
];
468472

469473
export const personalizedDigestWorkers: Worker[] = [

AGENTS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ This file provides guidance to coding agents when working with code in this repo
2121
- `pnpm run db:seed:import` - Import seed data for local development
2222
- `pnpm run db:migrate:make src/migration/MigrationName` - Generate new migration based on entity changes
2323
- `pnpm run db:migrate:create src/migration/MigrationName` - Create empty migration file
24+
- **Never use raw SQL queries** (`con.query()`) - always use TypeORM repository methods or query builder
25+
- If raw SQL is absolutely necessary, explain the reason and ask for permission before implementing
2426

2527
**Migration Generation:**
2628
When adding or modifying entity columns, **always generate a migration** using:
@@ -108,6 +110,7 @@ The migration generator compares entities against the local database schema. Ens
108110
- Fixtures in `__tests__/fixture/` for test data
109111
- Mercurius integration testing for GraphQL endpoints
110112
- Avoid creating multiple overlapping tests for the same scenario; a single test per key scenario is preferred
113+
- When evaluating response objects (GraphQL, API), prefer `toEqual` and `toMatchObject` over multiple `expect().toBe()` lines
111114

112115
**Infrastructure Concerns:**
113116
- OpenTelemetry for distributed tracing and metrics
@@ -131,6 +134,12 @@ The migration generator compares entities against the local database schema. Ens
131134
- Extract repeated patterns into small inline helpers (e.g., `const respond = (text) => ...`)
132135
- Combine related checks (e.g., `if (!match || match.status !== X)` instead of separate blocks)
133136

137+
**Function style:**
138+
- Prefer const arrow functions over function declarations: `const foo = () => {}` instead of `function foo() {}`
139+
- Prefer single props-style argument over multiple arguments: `const foo = ({ a, b }) => {}` instead of `const foo = (a, b) => {}`
140+
- Don't extract single-use code into separate functions - keep logic inline where it's used
141+
- Only extract functions when the same logic is needed in multiple places
142+
134143
**PubSub topics should be general-purpose:**
135144
- Topics should contain only essential identifiers (e.g., `{ opportunityId, userId }`)
136145
- Subscribers fetch their own data - don't optimize topic payloads for specific consumers
@@ -142,6 +151,11 @@ The migration generator compares entities against the local database schema. Ens
142151
- Example: Use `2 * ONE_DAY_IN_MINUTES` instead of `2 * 24 * 60`
143152
- Add new constants to `src/common/constants.ts` if needed (they are re-exported from `src/common/index.ts`)
144153

154+
**Type declarations:**
155+
- Only create separate exported types if they are used in multiple places
156+
- For single-use types, define them inline within the parent type
157+
- Example: Instead of `export type FileData = {...}; type Flags = { file: FileData }`, use `type Flags = { file: { ... } }`
158+
145159
## Best Practices & Lessons Learned
146160

147161
**Avoiding Code Duplication:**

0 commit comments

Comments
 (0)