Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds markdown excerpt extraction and word-count calculation to post sync: new extractor util and tests, markdown/AST deps, processor changes to derive description and wordCount, DB migration and schema update adding post_data.word_count, and stricter post metadata schema fields. Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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: 5
🧹 Nitpick comments (2)
apps/worker/src/tasks/sync-post/processor.test.ts (1)
61-73: Add one integration case without frontmatterdescription.This fixture still exercises only the authored-description path. A body-only markdown case would lock in the generated excerpt fallback and also cover the new simple-body word-count path.
Also applies to: 99-115
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/worker/src/tasks/sync-post/processor.test.ts` around lines 61 - 73, Add a new integration test in processor.test.ts that uses a markdown fixture missing the frontmatter "description" field (only frontmatter title/tags/date or even no frontmatter) and a body-only markdown content; in the new test assert that the processor falls back to generating an excerpt from the body (excerpt equals expected first N words/sentence) and that the word-count path uses the simple-body fallback (check whatever function output/field indicates wordCount or excerpt source). Locate nearby tests that use the `data` fixture and mirror their setup/assertions (same test suite) so the new case covers the authored-description-missing branch and the simple-body word-count/excerpt fallback.packages/db/drizzle/20260322121256_illegal_rick_jones/snapshot.json (1)
394-405: Enforce non-negativeword_countat the database layer.Line 394 defines
word_countas integer with default0, but without a check constraint negative values can still be written.Suggested constraint
+ALTER TABLE "post_data" +ADD CONSTRAINT "post_data_word_count_non_negative_chk" +CHECK ("word_count" >= 0);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/db/drizzle/20260322121256_illegal_rick_jones/snapshot.json` around lines 394 - 405, The snapshot shows the post_data.column word_count is integer with default 0 but no constraint preventing negatives; add a database-level CHECK constraint (e.g., ck_post_data_word_count_nonnegative or post_data_word_count_nonnegative) that enforces word_count >= 0 and include it in the schema/migration that defines/updates the post_data table (or in the Drizzle table definition for post_data) so the constraint is applied at the DB level while keeping the default 0.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/worker/src/tasks/sync-post/processor.ts`:
- Around line 101-106: Replace the current word-count calculation that splits
raw markdown (content.split(/\s+/).length) with a count derived from extracted
plain text: use the parsed plain-text field (parsed.text or whichever parsed
property holds plaintext) falling back to a markdown-stripped version of
content, call .trim() and then if the resulting string is empty set wordCount =
0, otherwise set wordCount = plain.split(/\s+/).length; update the assignment of
wordCount (the variable in the processor function) accordingly so empty-body
fixtures in processor.test.ts produce 0.
In `@apps/worker/src/utils/extractMarkdownExcerpt.ts`:
- Around line 7-20: The code is using hast types/utilities while
unifiedChain.parse returns mdast; update the imports and type checks to mdast
equivalents: import types from "mdast" (use mdast Content/Nodes types) and
import toString from "mdast-util-to-string" instead of hast versions, and ensure
unifiedChain is typed for mdast; in the type guard function isTextOrCode (and
any use of is(...)), replace hast node names with mdast names (e.g., "listitem"
-> "listItem") and adjust the union of node kinds to mdast node types like
"text", "code", "link", "listItem", "inlineCode" so the list-item branch becomes
reachable and type-safe.
In `@packages/db/drizzle/20260322121256_illegal_rick_jones/snapshot.json`:
- Around line 381-405: The snapshot for the "post_data" table is missing a
dedicated "excerpt" column: add a new not-null text column named "excerpt"
(similar to "description") to the post_data schema alongside "word_count" and
"description", update whatever migration or schema definition that defines the
post_data table (e.g., the createTable or table schema that contains post_data)
to include excerpt, run the migration/regeneration step to rebuild Drizzle
artifacts and regenerate snapshot.json so the new "excerpt" column appears in
the snapshot.
In `@packages/db/src/schema/posts.ts`:
- Around line 32-34: The posts schema lacks an excerpt column so generated
excerpts are never persisted: add a new column (e.g., excerpt:
text("excerpt").notNull().default("") or nullable per product choice) alongside
description and wordCount in packages/db/src/schema/posts.ts, add a
corresponding DB migration to create the excerpt column, and update all
write/read paths that populate post_data (including the worker that currently
only backfills description) so it writes the excerpt regardless of whether an
authored description exists and reads it when returning posts.
In `@pnpm-workspace.yaml`:
- Around line 6-15: Reformat pnpm-workspace.yaml with the repository’s Prettier
configuration so it matches CI expectations: open pnpm-workspace.yaml and run
the project’s formatter (the repo’s Prettier/format script) to rewrite the file
using the repo config, then stage and commit the updated file so CI no longer
reports formatting errors.
---
Nitpick comments:
In `@apps/worker/src/tasks/sync-post/processor.test.ts`:
- Around line 61-73: Add a new integration test in processor.test.ts that uses a
markdown fixture missing the frontmatter "description" field (only frontmatter
title/tags/date or even no frontmatter) and a body-only markdown content; in the
new test assert that the processor falls back to generating an excerpt from the
body (excerpt equals expected first N words/sentence) and that the word-count
path uses the simple-body fallback (check whatever function output/field
indicates wordCount or excerpt source). Locate nearby tests that use the `data`
fixture and mirror their setup/assertions (same test suite) so the new case
covers the authored-description-missing branch and the simple-body
word-count/excerpt fallback.
In `@packages/db/drizzle/20260322121256_illegal_rick_jones/snapshot.json`:
- Around line 394-405: The snapshot shows the post_data.column word_count is
integer with default 0 but no constraint preventing negatives; add a
database-level CHECK constraint (e.g., ck_post_data_word_count_nonnegative or
post_data_word_count_nonnegative) that enforces word_count >= 0 and include it
in the schema/migration that defines/updates the post_data table (or in the
Drizzle table definition for post_data) so the constraint is applied at the DB
level while keeping the default 0.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 05f27e3f-789b-4937-a3d3-018d843f4134
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (10)
apps/worker/package.jsonapps/worker/src/tasks/sync-post/processor.test.tsapps/worker/src/tasks/sync-post/processor.tsapps/worker/src/tasks/sync-post/types.tsapps/worker/src/utils/extractMarkdownExcerpt.test.tsapps/worker/src/utils/extractMarkdownExcerpt.tspackages/db/drizzle/20260322121256_illegal_rick_jones/migration.sqlpackages/db/drizzle/20260322121256_illegal_rick_jones/snapshot.jsonpackages/db/src/schema/posts.tspnpm-workspace.yaml
Fixes #99
Summary by CodeRabbit
New Features
Tests
Chores
Validation