Conversation
WalkthroughThis pull request refactors date handling across multiple seeder importer files to use a centralized utility. The 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
When seeder database timestamp strings were reparsed in non-UTC CI environments, they could shift into the future and make Faker reject inverted date ranges. Parsing those values as UTC and guarding the date range logic keeps the data generator test stable across timezones.
ce82048 to
554eb8a
Compare
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/server/data/seeders/importers/members-click-events-importer.js (1)
53-55: LGTM on the parse change, but note the inconsistency with other importers.Line 53 correctly uses
dateToDatabaseString.parse(). However, line 55 still usesfaker.date.between()directly while other importers in this PR switched todateToDatabaseString.randomBetween(). This may be intentional since the 15-minute window ensures a valid forward range, but consider updating for consistency.♻️ Optional: Use randomBetween for consistency
- const openedAt = dateToDatabaseString.parse(this.model.opened_at); - const laterOn = new Date(openedAt.getTime() + 1000 * 60 * 15); - const clickTime = faker.date.between(openedAt.getTime(), laterOn.getTime()); //added getTime here because it threw random errors + const openedAt = dateToDatabaseString.parse(this.model.opened_at); + const laterOn = new Date(openedAt.getTime() + 1000 * 60 * 15); + const clickTime = dateToDatabaseString.randomBetween(openedAt, laterOn);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/server/data/seeders/importers/members-click-events-importer.js` around lines 53 - 55, The code uses faker.date.between to compute clickTime while other importers use dateToDatabaseString.randomBetween; replace the faker call with dateToDatabaseString.randomBetween to keep behavior consistent (use openedAt and laterOn as the range to preserve the 15-minute window), i.e. compute clickTime via dateToDatabaseString.randomBetween(openedAt, laterOn) instead of faker.date.between(openedAt.getTime(), laterOn.getTime()); keep openedAt and laterOn as defined so the time window is unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@ghost/core/core/server/data/seeders/importers/members-click-events-importer.js`:
- Around line 53-55: The code uses faker.date.between to compute clickTime while
other importers use dateToDatabaseString.randomBetween; replace the faker call
with dateToDatabaseString.randomBetween to keep behavior consistent (use
openedAt and laterOn as the range to preserve the 15-minute window), i.e.
compute clickTime via dateToDatabaseString.randomBetween(openedAt, laterOn)
instead of faker.date.between(openedAt.getTime(), laterOn.getTime()); keep
openedAt and laterOn as defined so the time window is unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 29ad4bc7-ecd4-451b-be7a-373fdda1f968
📒 Files selected for processing (17)
ghost/core/core/server/data/seeders/importers/comment-reports-importer.jsghost/core/core/server/data/seeders/importers/comments-importer.jsghost/core/core/server/data/seeders/importers/email-batches-importer.jsghost/core/core/server/data/seeders/importers/email-recipients-importer.jsghost/core/core/server/data/seeders/importers/emails-importer.jsghost/core/core/server/data/seeders/importers/members-click-events-importer.jsghost/core/core/server/data/seeders/importers/members-created-events-importer.jsghost/core/core/server/data/seeders/importers/members-feedback-importer.jsghost/core/core/server/data/seeders/importers/members-login-events-importer.jsghost/core/core/server/data/seeders/importers/members-status-events-importer.jsghost/core/core/server/data/seeders/importers/members-stripe-customers-importer.jsghost/core/core/server/data/seeders/importers/members-stripe-customers-subscriptions-importer.jsghost/core/core/server/data/seeders/importers/members-subscribe-events-importer.jsghost/core/core/server/data/seeders/importers/members-subscription-created-events-importer.jsghost/core/core/server/data/seeders/importers/offer-redemptions-importer.jsghost/core/core/server/data/seeders/utils/database-date.jsghost/core/test/unit/server/data/seeders/data-generator.test.js



no issue
When seeder database timestamp strings were reparsed in non-UTC CI environments, they could shift into the future and make Faker reject inverted date ranges causing flaky CI failures. Parsing those values as UTC and guarding the date range logic keeps the data generator test stable across timezones.
What this does
Example flaky run: https://github.com/TryGhost/Ghost/actions/runs/23592298819/job/68700344677?pr=26958