Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Components - news_api #14487

Merged
merged 2 commits into from
Nov 4, 2024
Merged

New Components - news_api #14487

merged 2 commits into from
Nov 4, 2024

Conversation

michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Nov 1, 2024

Resolves #14474

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced "Search Everything" and "Top Headlines" actions for retrieving articles from a vast collection of news sources.
    • Added configurable properties for search queries, including keywords, categories, and languages.
  • Enhancements

    • Improved API interaction methods for better data retrieval and configuration options.
    • New constants for search options and languages to streamline user experience.
  • Version Update

    • Updated the component version to 0.1.0, reflecting new features and dependencies.

Copy link

vercel bot commented Nov 1, 2024

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

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Nov 1, 2024 6:28pm
pipedream-docs ⬜️ Ignored (Inspect) Nov 1, 2024 6:28pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Nov 1, 2024 6:28pm

Copy link
Contributor

coderabbitai bot commented Nov 1, 2024

Walkthrough

A new module for the "Search Everything" action has been added to the news API component, allowing users to search articles from over 150,000 sources. Additionally, a new action for retrieving top headlines has been introduced, along with constants for search options and a utility function for joining arrays. Enhancements to the news_api application include new properties and methods for API interaction. The package.json file has been updated to reflect a new version and added dependencies.

Changes

File Path Change Summary
components/news_api/actions/search-everything/... New module for "Search Everything" action with properties and run method.
components/news_api/actions/search-top-headlines/... New action for retrieving top headlines with properties and run method.
components/news_api/common/constants.mjs New constants defined: SEARCH_IN_OPTIONS, SORT_OPTIONS, and LANGUAGES.
components/news_api/common/utils.mjs New utility function joinArray added for joining array elements.
components/news_api/news_api.app.mjs New properties and methods added for API interaction, including sourceIds, searchin, etc.
components/news_api/package.json Version updated from 0.0.1 to 0.1.0, and new dependencies added.

Assessment against linked issues

Objective Addressed Explanation
Enhance news API functionality
Implement new search actions
Update documentation references No changes made to documentation.

Suggested labels

action

Suggested reviewers

  • jcortes

Poem

🐰 In the meadow, news does bloom,
With articles that chase away gloom.
Search for headlines, near and far,
From every source, like a shining star.
New features hop, with joy they sing,
In the world of news, let freedom ring! 📜✨


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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: 13

🧹 Outside diff range and nitpick comments (3)
components/news_api/common/constants.mjs (2)

1-5: Add JSDoc documentation for the SEARCH_IN_OPTIONS constant.

While the implementation is correct, adding documentation would improve maintainability and help other developers understand the purpose of these search options.

+/**
+ * Valid fields that can be searched in the NewsAPI.
+ * @see https://newsapi.org/docs/endpoints/everything#search-in
+ */
const SEARCH_IN_OPTIONS = [

7-11: Add JSDoc documentation for the SORT_OPTIONS constant.

Adding documentation would clarify the purpose of each sort option.

+/**
+ * Available sorting options for news articles.
+ * - relevancy: Articles more closely related to search query come first
+ * - popularity: Articles from popular sources and publishers come first
+ * - publishedAt: Newest articles come first
+ * @see https://newsapi.org/docs/endpoints/everything#sortBy
+ */
const SORT_OPTIONS = [
components/news_api/actions/search-top-headlines/search-top-headlines.mjs (1)

5-11: Enhance the action description with more details.

While the description includes a link to the documentation, it would be helpful to add:

  • Example use cases
  • Information about rate limits or API key requirements
  • Brief explanation of the difference between this and the search-everything endpoint
-  description: "Retrieve live top and breaking headlines for a category, single source, multiple sources, or keywords. [See the documentation](https://newsapi.org/docs/endpoints/top-headlines)",
+  description: "Retrieve live top and breaking headlines filtered by category, source, or keywords. Ideal for displaying breaking news tickers, news monitoring, and content curation. Requires API key and respects rate limits. For historical articles, use the Search Everything action instead. [See the documentation](https://newsapi.org/docs/endpoints/top-headlines)",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 02197b3 and f4ebd5b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/news_api/actions/search-everything/search-everything.mjs (1 hunks)
  • components/news_api/actions/search-top-headlines/search-top-headlines.mjs (1 hunks)
  • components/news_api/common/constants.mjs (1 hunks)
  • components/news_api/common/utils.mjs (1 hunks)
  • components/news_api/news_api.app.mjs (1 hunks)
  • components/news_api/package.json (2 hunks)
🔇 Additional comments (10)
components/news_api/common/utils.mjs (2)

8-10: LGTM!

The export statement follows modern ES module syntax and is implemented correctly.


1-10: Verify consistent usage across the codebase.

Let's verify how the joinArray function is being used in the search modules to ensure consistent implementation.

components/news_api/package.json (2)

15-17: Verify platform dependency version compatibility.

The addition of @pipedream/platform dependency is correct for a new component. The caret range (^3.0.3) allows for compatible updates.

✅ Verification successful

Platform dependency version is consistent with other components

The version ^3.0.3 of @pipedream/platform used in the news_api component matches the version used across many other components in the codebase. Some components use the exact version 3.0.3 while others use the caret range ^3.0.3, both of which are compatible.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify other news_api components use the same platform version
# Expect: Consistent platform versions across related components

# Search for platform dependency in other component package.json files
fd -e json package.json | xargs rg "@pipedream/platform.*3\.0\.3"

Length of output: 4988


3-3: Verify semver compliance for version bump.

The version bump from 0.0.1 to 0.1.0 correctly reflects the addition of new features (search everything, top headlines) without breaking changes.

✅ Verification successful

Version bump to 0.1.0 follows semantic versioning guidelines

The version bump from 0.0.1 to 0.1.0 is appropriate as:

  • No major version (1.x.x) tags or releases exist, confirming this is still pre-1.0
  • The minor version increment correctly reflects new feature additions (search everything, top headlines) without breaking changes
  • The component uses the standard @pipedream/platform@^3.0.3 dependency version, consistent with many other components in the repository
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify this is the first minor version bump and no major version exists
# Expect: No tags or releases with version 1.x.x should exist

# Check git tags
git tag | grep -E "^v?1\."

# Check GitHub releases
gh release list | grep -E "^v?1\."

Length of output: 4988

components/news_api/actions/search-top-headlines/search-top-headlines.mjs (3)

1-4: LGTM: Clean imports with appropriate dependencies.

The imports are well-organized and include all necessary dependencies for the component.


40-42: LGTM: Good validation of mutual exclusivity.

The configuration error check is well-implemented and provides a clear error message.


71-71: 🛠️ Refactor suggestion

Consider sanitizing the response data.

The articles array is returned directly from the external API without any sanitization or transformation.

Consider adding a transform function to sanitize and standardize the response:

const transformArticle = (article) => ({
  id: article.id,
  title: article.title,
  description: article.description,
  url: article.url,
  publishedAt: article.publishedAt,
  // Add only necessary fields
});

return articles.map(transformArticle);
components/news_api/actions/search-everything/search-everything.mjs (2)

1-9: LGTM! Well-structured metadata and imports.

The metadata is well-defined with clear descriptions and proper versioning.


1-2: Verify newsapi module integration.

Let's verify that all required methods and prop definitions exist in the newsapi module.

Also applies to: 11-71

✅ Verification successful

Let me gather more information by checking the actual content of the newsapi module and the search-everything action.


Integration with newsapi module is properly implemented

The verification shows that:

  • The searchEverything method exists in the newsapi module and matches the usage in the action
  • All required prop definitions (q, searchin, sourceIds, language, sortBy, maxResults) are correctly defined in the newsapi module and properly referenced in the action
  • The imports are correctly pointing to the right modules
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the newsapi module contains all required methods and prop definitions

# Test 1: Check for searchEverything method
echo "Checking for searchEverything method..."
ast-grep --pattern 'searchEverything($$$) { $$$ }' components/news_api/news_api.app.mjs

# Test 2: Check for required prop definitions
echo "Checking for required prop definitions..."
for prop in "q" "searchin" "sourceIds" "language" "sortBy" "maxResults"; do
  echo "Checking for $prop prop definition..."
  ast-grep --pattern "propDefinitions: { $$$ $prop: { $$$ } $$$ }" components/news_api/news_api.app.mjs
done

Length of output: 1939


Script:

#!/bin/bash
# Let's examine the content of both files
echo "=== Content of news_api.app.mjs ==="
cat components/news_api/news_api.app.mjs

echo -e "\n=== Content of search-everything.mjs ==="
cat components/news_api/actions/search-everything/search-everything.mjs

Length of output: 5100

components/news_api/news_api.app.mjs (1)

73-89: Ensure proper parameter handling in API methods

The methods listSources, searchEverything, and searchTopHeadlines pass opts directly to _makeRequest, but it's unclear how query parameters are handled. Ensure that query parameters are correctly set in the Axios request.

Confirm that any query parameters are included under the params key in opts. For example:

searchEverything(opts = {}) {
  return this._makeRequest({
    path: "/everything",
    params: opts,
  });
}

If opts already contains a params object, make sure it is correctly structured.

components/news_api/common/utils.mjs Show resolved Hide resolved
components/news_api/common/constants.mjs Show resolved Hide resolved
components/news_api/common/constants.mjs Show resolved Hide resolved
components/news_api/news_api.app.mjs Show resolved Hide resolved
components/news_api/news_api.app.mjs Show resolved Hide resolved
components/news_api/news_api.app.mjs Show resolved Hide resolved
components/news_api/news_api.app.mjs Show resolved Hide resolved
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

@michelle0927 michelle0927 merged commit 6bed164 into master Nov 4, 2024
12 checks passed
@michelle0927 michelle0927 deleted the issue-14474 branch November 4, 2024 15:30
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.

[Components] news_api
2 participants