Skip to content

Conversation

@jcortes
Copy link
Collaborator

@jcortes jcortes commented Sep 10, 2024

… blocks each

WHY

Added chunkArray function to get chunks of 1000 blocks each

Resolves #13857

Summary by CodeRabbit

  • New Features

    • Introduced a method for processing large arrays in manageable chunks, improving performance when appending blocks.
    • Updated user feedback to reflect the total number of blocks appended after processing.
  • Chores

    • Updated the version of the @pipedream/notion package to 0.1.20.

@jcortes jcortes added the enhancement New feature or request label Sep 10, 2024
@jcortes jcortes self-assigned this Sep 10, 2024
@vercel
Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Sep 13, 2024 2:08pm

@vercel
Copy link

vercel bot commented Sep 10, 2024

@jcortes is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 10, 2024

Walkthrough

The pull request introduces a new method, chunkArray, to the append-block.mjs file, enabling the processing of large arrays by dividing them into smaller chunks. The run method is updated to append blocks in manageable sizes, improving the handling of larger datasets. Additionally, the version of the @pipedream/notion package is updated from 0.1.19 to 0.1.20, indicating a new release.

Changes

File Path Change Summary
components/notion/actions/append-block/append-block.mjs Added chunkArray(array, chunkSize = 100) method; modified run method to append blocks in chunks.
components/notion/package.json Updated version from 0.1.19 to 0.1.20.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NotionAPI
    participant AppendBlock

    User->>AppendBlock: Request to append blocks
    AppendBlock->>AppendBlock: chunkArray(children)
    AppendBlock->>NotionAPI: Append chunk of blocks
    NotionAPI-->>AppendBlock: Return results
    AppendBlock->>AppendBlock: Collect results
    AppendBlock->>User: Total blocks appended
Loading

Assessment against linked issues

Objective Addressed Explanation
Improve Notion actions to loop block-creation, comply with request limits (#13857)
Allow for an arbitrary number of blocks to be created beyond the limits of a single request (#13857)

🐇 "In the garden, blocks do play,
Chunks of joy, in a neat array.
With each request, we leap and bound,
Appending tales where dreams are found!
Hop along, dear friends, don’t delay,
For every block, a new story today!" 🌼

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8239d54 and 7761203.

Files selected for processing (2)
  • components/notion/actions/append-block/append-block.mjs (3 hunks)
  • components/notion/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • components/notion/actions/append-block/append-block.mjs
  • components/notion/package.json

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 0

Outside diff range, codebase verification and nitpick comments (2)
components/notion/actions/append-block/append-block.mjs (2)

51-57: The chunkArray method implementation looks good.

The method correctly splits the input array into chunks of the specified size and can handle arrays smaller than the chunk size.

Consider using Array.from for a more concise implementation.

You can replace the for loop with Array.from to make the implementation more concise:

chunkArray(array, chunkSize = 1000) {
  return Array.from({ length: Math.ceil(array.length / chunkSize) }, (_, i) =>
    array.slice(i * chunkSize, (i + 1) * chunkSize)
  );
}

109-115: The changes to the run method look good.

The changes allow appending blocks in manageable sizes, which is useful for handling larger datasets and complies with the Notion API's request limits.

Consider adding error handling.

The run method should handle potential errors that may occur while appending blocks. You can wrap the block appending logic in a try-catch block and handle errors appropriately.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d17371 and a96a126.

Files selected for processing (2)
  • components/notion/actions/append-block/append-block.mjs (3 hunks)
  • components/notion/package.json (1 hunks)
Files skipped from review due to trivial changes (1)
  • components/notion/package.json
Additional comments not posted (2)
components/notion/actions/append-block/append-block.mjs (2)

9-9: Version update looks good.

The version change from 0.2.13 to 0.2.14 is approved.


117-119: The changes to the summary message look good.

The changes correctly calculate and report the total number of appended blocks, enhancing the feedback provided to the user.

michelle0927
michelle0927 previously approved these changes Sep 11, 2024
Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jcortes jcortes force-pushed the notion-improve-actions-to-loop-block-creation-comply-with-request-limits branch from a96a126 to b95434f Compare September 12, 2024 16:43
@jcortes jcortes force-pushed the notion-improve-actions-to-loop-block-creation-comply-with-request-limits branch from 8239d54 to 7761203 Compare September 13, 2024 14:08
@jcortes
Copy link
Collaborator Author

jcortes commented Sep 13, 2024

/approve

@jcortes jcortes merged commit 3fb8853 into PipedreamHQ:master Sep 13, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Development

Successfully merging this pull request may close these issues.

[ACTION] Improve Notion actions to loop block-creation, comply with request limits

3 participants