feat: enhance demo data seeding with documents and interview schedules#106
feat: enhance demo data seeding with documents and interview schedules#106JoachimLK wants to merge 1 commit into
Conversation
|
🚅 Deployed to the reqcore-pr-106 environment in applirank
|
📝 WalkthroughWalkthroughThe pull request expands content scope from 132 to 153 articles, extends phase timelines across four phases, and reorganizes clusters including a new Cluster 10 for ATS Integrations. Seed script enhancements add document and interview seeding capabilities with utility functions and idempotent execution. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 717-727: The current idempotency check only inspects
schema.interview via the existingInterview query, which can cause partial
seeding; instead wrap the helper in a single transaction (use db.transaction)
and perform table-specific existence checks against schema.document and
schema.interview (e.g., similar to the existingInterview/select/eq pattern)
inside that transaction, then insert only the missing documents or missing
interviews (do not short-circuit both based on one table), and commit or
rollback the transaction so the additive seed is atomic and each table is
backfilled independently.
- Around line 113-116: The atHour function creates Date objects using setHours
(local machine timezone), causing scheduledAt to be misinterpreted when rows are
marked timezone: 'Europe/Berlin'; fix by making atHour produce a timezone-aware
timestamp that matches the persisted timezone: either (A) convert to Berlin time
using a tz-aware library (e.g., date-fns-tz or dayjs with timezone) so
atHour(date, hour, minute) builds the Date in 'Europe/Berlin' before saving, or
(B) switch persistence to UTC by changing the timezone assignment (the code that
sets timezone: 'Europe/Berlin') to 'UTC' and update atHour to use UTC setters
(setUTCHours) so stored timestamps and the timezone flag agree; update all
places that call atHour and the timezone assignment to keep them consistent
(refer to the atHour function and the timezone: 'Europe/Berlin' assignment).
In `@TOPICAL-AUTHORITY-MAP.md`:
- Line 122: The progress counter in the Phase 1 header ("**Phase 1 total: 41
articles** | Progress: 6/41") is incorrect—update the Progress portion to match
the actual completed count shown in the checklist and summary table by changing
"Progress: 6/41" to "Progress: 9/41" (ensure the string "Progress: 6/41" is
replaced accordingly); also scan the Phase 1 checklist and the summary table to
confirm consistency so future edits won't diverge.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f8c40bd8-f0e2-485e-a254-c28b636d8485
📒 Files selected for processing (2)
TOPICAL-AUTHORITY-MAP.mdserver/scripts/seed.ts
| function atHour(date: Date, hour: number, minute = 0): Date { | ||
| const d = new Date(date) | ||
| d.setHours(hour, minute, 0, 0) | ||
| return d |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's check the file exists and get its size
wc -l server/scripts/seed.tsRepository: reqcore-inc/reqcore
Length of output: 89
🏁 Script executed:
# Read the atHour function and surrounding context (lines 110-120)
sed -n '110,120p' server/scripts/seed.tsRepository: reqcore-inc/reqcore
Length of output: 377
🏁 Script executed:
# Read the code around line 959 to see the timezone assignment
sed -n '955,965p' server/scripts/seed.tsRepository: reqcore-inc/reqcore
Length of output: 467
🏁 Script executed:
# Search for all uses of atHour to understand how it's being called
rg "atHour" server/scripts/seed.ts -n -B 2 -A 2Repository: reqcore-inc/reqcore
Length of output: 1801
🏁 Script executed:
# Search for timezone references in the file to understand the full context
rg "timezone" server/scripts/seed.ts -n -B 1 -A 1Repository: reqcore-inc/reqcore
Length of output: 215
🏁 Script executed:
# Find daysAgo and daysFromNow function definitions
rg "function daysAgo|function daysFromNow|const daysAgo|const daysFromNow|export.*daysAgo|export.*daysFromNow" server/scripts/seed.ts -n -A 3Repository: reqcore-inc/reqcore
Length of output: 299
🏁 Script executed:
# Check imports at the top of seed.ts to see where these utilities come from
head -30 server/scripts/seed.tsRepository: reqcore-inc/reqcore
Length of output: 1116
🏁 Script executed:
# Search for timezone field usage across the codebase to understand how it's consumed
rg "timezone" --type ts --type tsx -n -B 1 -A 1 | head -100Repository: reqcore-inc/reqcore
Length of output: 90
🏁 Script executed:
# Look for database schema or models related to interviews and timezone
rg "scheduledAt" --type ts --type tsx -n -B 2 -A 2 | head -80Repository: reqcore-inc/reqcore
Length of output: 90
🏁 Script executed:
# Search for timezone field usage without tsx type filter
rg "timezone" -n -B 1 -A 1 | grep -E "(\.timezone|interview|scheduledAt)" | head -50Repository: reqcore-inc/reqcore
Length of output: 4541
🏁 Script executed:
# Look at the database schema for interviews to understand the timezone field
rg "timezone" server/database/schema.ts -n -B 2 -A 2Repository: reqcore-inc/reqcore
Length of output: 128
🏁 Script executed:
# Check if there are any timezone conversion utilities being used anywhere
rg "toZonedTime|formatInTimeZone|tzOffsetFrom|getTimezoneOffset" -nRepository: reqcore-inc/reqcore
Length of output: 45
🏁 Script executed:
# Look at how interviews are queried and used in the frontend/API
fd -e ts -e js | xargs grep -l "scheduledAt" | grep -v node_modules | head -10Repository: reqcore-inc/reqcore
Length of output: 430
🏁 Script executed:
# Check if timezone field is used in any interview display or transformation logic
rg "interview" server/database/schema.ts -n -A 5 | grep -A 5 "timezone"Repository: reqcore-inc/reqcore
Length of output: 128
🏁 Script executed:
# Find the database schema file
fd "schema" --type f -e ts | grep -v node_modules | head -20Repository: reqcore-inc/reqcore
Length of output: 45
🏁 Script executed:
# Look at the google-calendar utility to understand how timezone is used
sed -n '290,305p' server/utils/google-calendar.tsRepository: reqcore-inc/reqcore
Length of output: 548
🏁 Script executed:
# Get more context around the Google Calendar timezone usage
sed -n '350,365p' server/utils/google-calendar.tsRepository: reqcore-inc/reqcore
Length of output: 604
🏁 Script executed:
# Check how the scheduledAt timestamp is created/stored in the database
rg "scheduledAt" server/api/interviews/index.post.ts -n -B 3 -A 3Repository: reqcore-inc/reqcore
Length of output: 803
🏁 Script executed:
# Check the send-invitation logic to see how the timezone is applied to the scheduledAt time
cat server/api/interviews/\[id\]/send-invitation.post.ts | head -200Repository: reqcore-inc/reqcore
Length of output: 7345
🏁 Script executed:
# Check if there are any timezone conversion libraries imported or used
rg "date-fns|dayjs|moment|tz|timezone" server/scripts/seed.ts -nRepository: reqcore-inc/reqcore
Length of output: 433
🏁 Script executed:
# Look at the database schema for the interview table to confirm how scheduledAt is stored
sed -n '1,50p' server/database/schema/app.ts | grep -A 20 "interview"Repository: reqcore-inc/reqcore
Length of output: 932
🏁 Script executed:
# Check if there are timezone conversion utilities in the utils directory
fd -e ts -path "*/utils/*" | xargs grep -l "timezone\|toZonedTime\|formatInTimeZone" 2>/dev/nullRepository: reqcore-inc/reqcore
Length of output: 233
🏁 Script executed:
# Let's examine the exact flow: how the seed timestamp ends up being used
# Check the ICS generation to see if it's timezone-aware
rg "generateInterviewICS" server/utils/ical.ts -n -A 30 | head -50Repository: reqcore-inc/reqcore
Length of output: 1397
🏁 Script executed:
# Check if scheduledAt in the database stores the raw Date or if there's any conversion
rg "scheduledAt" server/database/schema/app.ts -n -B 2 -A 2Repository: reqcore-inc/reqcore
Length of output: 661
🏁 Script executed:
# Check if there are any timezone utilities in the codebase
find server/utils -name "*.ts" -type f | xargs ls -laRepository: reqcore-inc/reqcore
Length of output: 2377
🏁 Script executed:
# Look at how formatDateTimeUTC works to understand UTC handling
rg "formatDateTimeUTC" server/utils/ical.ts -n -B 2 -A 5Repository: reqcore-inc/reqcore
Length of output: 1811
🏁 Script executed:
# Check if there's any timezone conversion happening when data is written to DB
rg "scheduledAt" server/api/interviews/index.post.ts -n -B 5 -A 5Repository: reqcore-inc/reqcore
Length of output: 1212
🏁 Script executed:
# Let's trace the complete flow: what happens when we insert a seeded interview
# Check what the actual stored value looks like by examining the schema
cat server/database/schema/app.ts | grep -A 30 "export const interview = pgTable"Repository: reqcore-inc/reqcore
Length of output: 1915
🏁 Script executed:
# Check if date-fns or similar timezone libraries are used anywhere in the project
rg "date-fns|dayjs|moment" package.jsonRepository: reqcore-inc/reqcore
Length of output: 45
Build scheduledAt in the same timezone you persist.
atHour() uses Date#setHours(), which applies the machine's local timezone. Every inserted row is tagged as timezone: 'Europe/Berlin'. If this seed runs on a UTC or US host, the wall-clock time stored in the scheduledAt field will drift when interpreted as Berlin time—by hours in the UI, Google Calendar sync, and email invitations. Either seed the timestamp in Berlin time (using a timezone library like date-fns), or store UTC and set timezone: 'UTC'.
Applies to lines 113–116 (atHour definition) and 959 (timezone assignment).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@server/scripts/seed.ts` around lines 113 - 116, The atHour function creates
Date objects using setHours (local machine timezone), causing scheduledAt to be
misinterpreted when rows are marked timezone: 'Europe/Berlin'; fix by making
atHour produce a timezone-aware timestamp that matches the persisted timezone:
either (A) convert to Berlin time using a tz-aware library (e.g., date-fns-tz or
dayjs with timezone) so atHour(date, hour, minute) builds the Date in
'Europe/Berlin' before saving, or (B) switch persistence to UTC by changing the
timezone assignment (the code that sets timezone: 'Europe/Berlin') to 'UTC' and
update atHour to use UTC setters (setUTCHours) so stored timestamps and the
timezone flag agree; update all places that call atHour and the timezone
assignment to keep them consistent (refer to the atHour function and the
timezone: 'Europe/Berlin' assignment).
| // Idempotency: skip if interviews already exist for this org | ||
| const [existingInterview] = await db | ||
| .select({ id: schema.interview.id }) | ||
| .from(schema.interview) | ||
| .where(eq(schema.interview.organizationId, orgId)) | ||
| .limit(1) | ||
|
|
||
| if (existingInterview) { | ||
| console.log('ℹ️ Documents & interviews already seeded. Skipping.') | ||
| return | ||
| } |
There was a problem hiding this comment.
Make the additive seed atomic and table-specific.
This guard only checks interview rows, but the function inserts document rows first. If a run fails after creating some documents and before the first interview insert, rerunning will create a second set of resumes; the opposite case also blocks document backfill entirely once any interview exists. Please wrap this helper in a transaction and gate/backfill documents and interviews independently.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@server/scripts/seed.ts` around lines 717 - 727, The current idempotency check
only inspects schema.interview via the existingInterview query, which can cause
partial seeding; instead wrap the helper in a single transaction (use
db.transaction) and perform table-specific existence checks against
schema.document and schema.interview (e.g., similar to the
existingInterview/select/eq pattern) inside that transaction, then insert only
the missing documents or missing interviews (do not short-circuit both based on
one table), and commit or rollback the transaction so the additive seed is
atomic and each table is backfilled independently.
| --- | ||
|
|
||
| **Phase 1 total: 35 articles** | Progress: 6/35 | ||
| **Phase 1 total: 41 articles** | Progress: 6/41 |
There was a problem hiding this comment.
Fix the Phase 1 progress counter.
This line says 6/41, but the checked items in Phase 1 already add up to 9 completed articles, and the summary table below also totals 9 done. Leaving both numbers in the same document will cause churn the next time someone updates the roadmap.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@TOPICAL-AUTHORITY-MAP.md` at line 122, The progress counter in the Phase 1
header ("**Phase 1 total: 41 articles** | Progress: 6/41") is incorrect—update
the Progress portion to match the actual completed count shown in the checklist
and summary table by changing "Progress: 6/41" to "Progress: 9/41" (ensure the
string "Progress: 6/41" is replaced accordingly); also scan the Phase 1
checklist and the summary table to confirm consistency so future edits won't
diverge.
Summary
Type of change
Validation
DCO
Signed-off-by) viagit commit -sSummary by CodeRabbit
Documentation
Chores