Skip to content

Add ai analysis demo data to the demo account#115

Merged
JoachimLK merged 2 commits intomainfrom
feat/ai-analysis-demo-data
Mar 18, 2026
Merged

Add ai analysis demo data to the demo account#115
JoachimLK merged 2 commits intomainfrom
feat/ai-analysis-demo-data

Conversation

@JoachimLK
Copy link
Copy Markdown
Contributor

@JoachimLK JoachimLK commented Mar 18, 2026

Summary

  • What does this PR change?
  • Why is this needed?

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Chore

Validation

  • I tested locally
  • I added/updated relevant documentation
  • I verified multi-tenant scoping and auth behavior for affected API paths

DCO

  • All commits in this PR are signed off (Signed-off-by) via git commit -s

Summary by CodeRabbit

  • New Features

    • AI-driven application scoring with multi-criteria evaluations and composite scores
    • Auto-scoring enabled for applications (first demo job)
    • Detailed scoring analysis surfaced: per-criterion evaluations, evidence, strengths, and gaps
  • Chores

    • Demo reset tool to remove demo organization, demo user, and associated scoring data

@railway-app railway-app Bot temporarily deployed to applirank / reqcore-pr-115 March 18, 2026 10:26 Destroyed
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Mar 18, 2026

🚅 Deployed to the reqcore-pr-115 environment in applirank

Service Status Web Updated (UTC)
applirank ✅ Success (View Logs) Web Mar 18, 2026 at 11:16 am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

Adds AI-driven scoring data and seeding logic to the demo seed flow and a new reset script to remove demo AI scoring and demo org/user; seeds criteria, per-application scores, analysis runs, an audit snapshot, and an encrypted demo AI config, then enables auto-score on the first job.

Changes

Cohort / File(s) Summary
AI scoring seed additions
server/scripts/seed.ts
Adds internal types for scoring seeds, defines JOB_0_CRITERIA, JOB_1_CRITERIA, JOB_2_CRITERIA and AI_SCORING_DATA. Seeds scoring criteria, criterion scores, analysis runs, and an analysis audit snapshot; inserts encrypted AI config and enables autoScoreOnApply on first job.
Demo reset script
server/scripts/reset-demo.ts
New script that connects to Postgres via drizzle-orm, finds the demo organization and demo user, deletes related scoring criteria and records, and removes the org/user. Includes error handling and DB client shutdown.
Integration / utilities
server/scripts/...seed.ts (imports) , server/utils/encryption.ts
Imports and uses encrypt from encryption util to store an encrypted demo API key in seeded AI config. Minor control-flow integration in seed ordering (AI seeding before interview seeding).

Sequence Diagram(s)

sequenceDiagram
  participant Seed as "Seed Script"
  participant Encrypt as "Encryption Util"
  participant DB as "Postgres (drizzle-orm)"
  participant Logger as "Console/Logs"

  Note over Seed,DB: AI scoring seeding flow
  Seed->>DB: Insert scoring criteria per job (JOB_*_CRITERIA)
  DB-->>Seed: Criteria created (IDs)
  Seed->>Encrypt: encrypt(demoApiKey, secret)
  Encrypt-->>Seed: encryptedKey
  Seed->>DB: Insert aiConfig with encryptedKey
  DB-->>Seed: aiConfig persisted
  loop per application in AI_SCORING_DATA
    Seed->>DB: Insert CriterionScore records + AnalysisRun (rawResponse, token counts)
    DB-->>Seed: Scores + AnalysisRun IDs
    Seed->>DB: Create analysis audit with criteria snapshot & composite score
    DB-->>Seed: Audit created
  end
  Seed->>DB: Update first job: set autoScoreOnApply = true
  DB-->>Seed: Update acknowledged
  Seed->>Logger: Log totals and demo cost
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hop through rows of seeded gold,
I tuck encrypted keys in burrows bold,
I count the scores, each strength and gap,
I log the hops on a demo map,
Hooray — the AI seeds are sown! 🥕✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely templated with all fields empty; no actual details about changes, rationale, or validation status are provided despite substantial implementation work. Fill in the summary section with specific details about AI scoring implementation and demo reset script, check appropriate change type, and verify validation requirements were completed.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely describes the main change: adding AI analysis demo data to the demo account, which aligns with the core modifications in seed.ts and reset-demo.ts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/ai-analysis-demo-data
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/scripts/seed.ts`:
- Around line 504-510: The seed currently stores a hand-maintained
compositeScore in ApplicationScoringSeed and writes criterionScore rows,
application.score and analysisRun in separate statements (see the block around
lines 2127-2181), which can drift from computeCompositeScore(); change the seed
to remove/ignore the manual compositeScore and instead call the shared
computeCompositeScore() (from server/utils/ai/autoScore.ts) to derive the
composite, then persist the criterionScore rows, update application.score and
insert analysisRun inside a single database transaction so the three related
writes are atomic and reruns don't leave partial state.
- Around line 2187-2191: The seed turns on autoScoreOnApply for the first seeded
job (using jobIds and db.update(schema.job).set({ autoScoreOnApply: true })
where eq(schema.job.id, firstJobId)), which can trigger real AI calls; change
this so autoScoreOnApply remains false by default and only gets set when an
explicit env var is present (e.g., process.env.ENABLE_AUTO_SCORE_IN_SEEDS ===
'true'). Modify the block around firstJobId to check that env var before calling
db.update(schema.job).set(...), or simply remove the update to keep the flag off
in seeds; reference autoScoreOnApply, jobIds, db.update, and schema.job when
making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cc7f16fb-7134-4067-8835-c99c213a8722

📥 Commits

Reviewing files that changed from the base of the PR and between 6ba3159 and 8eb2ef2.

📒 Files selected for processing (1)
  • server/scripts/seed.ts

Comment thread server/scripts/seed.ts
Comment on lines +504 to +510
interface ApplicationScoringSeed {
jobIndex: number
candidateIndex: number
compositeScore: number
scores: CriterionScoreSeed[]
summary: string
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Derive seeded composite scores from the rubric and persist them atomically.

Line 507 makes compositeScore another hand-maintained field, and Lines 2127-2181 then write the related score rows and analysisRun in separate statements. The first full-stack seed entry already drifts from the rubric — 10/9/10/9/9 over weights 70/55/40/50/30 is about 94, not 96 — so this can create demo data that computeCompositeScore() in server/utils/ai/autoScore.ts would never produce. Please compute the score once with the shared helper and persist criterionScore, application.score, and analysisRun in a single transaction; otherwise a mid-loop failure leaves a partial seed that reruns will skip.

Also applies to: 2127-2181

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/scripts/seed.ts` around lines 504 - 510, The seed currently stores a
hand-maintained compositeScore in ApplicationScoringSeed and writes
criterionScore rows, application.score and analysisRun in separate statements
(see the block around lines 2127-2181), which can drift from
computeCompositeScore(); change the seed to remove/ignore the manual
compositeScore and instead call the shared computeCompositeScore() (from
server/utils/ai/autoScore.ts) to derive the composite, then persist the
criterionScore rows, update application.score and insert analysisRun inside a
single database transaction so the three related writes are atomic and reruns
don't leave partial state.

Comment thread server/scripts/seed.ts
Comment on lines +2187 to +2191
// Enable autoScoreOnApply on the Senior Full-Stack Engineer job to showcase the feature
const firstJobId = jobIds[0]
if (firstJobId) {
await db.update(schema.job).set({ autoScoreOnApply: true }).where(eq(schema.job.id, firstJobId))
console.log(`✅ Enabled auto-score on apply for: ${JOBS_DATA[0]?.title}`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep autoScoreOnApply off by default in seed data.

Lines 2187-2191 turn this on for a seeded public job. server/api/public/jobs/[slug]/apply.post.ts will call autoScoreApplication() on every new application when this flag is true, and server/utils/ai/autoScore.ts can then hit the external provider once AI config exists. That makes the seed quietly opt environments into real AI spend; gate it behind an env var or leave it disabled by default.

⚙️ Suggested guard
-  const firstJobId = jobIds[0]
-  if (firstJobId) {
+  const firstJobId = jobIds[0]
+  if (process.env.SEED_ENABLE_AUTO_SCORE_DEMO === 'true' && firstJobId) {
     await db.update(schema.job).set({ autoScoreOnApply: true }).where(eq(schema.job.id, firstJobId))
     console.log(`✅ Enabled auto-score on apply for: ${JOBS_DATA[0]?.title}`)
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Enable autoScoreOnApply on the Senior Full-Stack Engineer job to showcase the feature
const firstJobId = jobIds[0]
if (firstJobId) {
await db.update(schema.job).set({ autoScoreOnApply: true }).where(eq(schema.job.id, firstJobId))
console.log(`✅ Enabled auto-score on apply for: ${JOBS_DATA[0]?.title}`)
// Enable autoScoreOnApply on the Senior Full-Stack Engineer job to showcase the feature
const firstJobId = jobIds[0]
if (process.env.SEED_ENABLE_AUTO_SCORE_DEMO === 'true' && firstJobId) {
await db.update(schema.job).set({ autoScoreOnApply: true }).where(eq(schema.job.id, firstJobId))
console.log(`✅ Enabled auto-score on apply for: ${JOBS_DATA[0]?.title}`)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/scripts/seed.ts` around lines 2187 - 2191, The seed turns on
autoScoreOnApply for the first seeded job (using jobIds and
db.update(schema.job).set({ autoScoreOnApply: true }) where eq(schema.job.id,
firstJobId)), which can trigger real AI calls; change this so autoScoreOnApply
remains false by default and only gets set when an explicit env var is present
(e.g., process.env.ENABLE_AUTO_SCORE_IN_SEEDS === 'true'). Modify the block
around firstJobId to check that env var before calling
db.update(schema.job).set(...), or simply remove the update to keep the flag off
in seeds; reference autoScoreOnApply, jobIds, db.update, and schema.job when
making the change.

@railway-app railway-app Bot temporarily deployed to applirank / reqcore-pr-115 March 18, 2026 11:13 Destroyed
@JoachimLK JoachimLK changed the title Implement feature X to enhance user experience and fix bug Y in module Z Add ai analysis demo data to the demo account Mar 18, 2026
@JoachimLK JoachimLK merged commit 336fb60 into main Mar 18, 2026
4 of 5 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