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

Better handling for NaN in betting lines #96

Merged
merged 5 commits into from
Feb 1, 2024
Merged

Conversation

akeaswaran
Copy link
Collaborator

@akeaswaran akeaswaran commented Dec 17, 2023

Closes #93.

Summary by CodeRabbit

  • Enhancements
    • Improved data processing logic in the betting lines feature for more accurate and refined results.

Copy link

vercel bot commented Dec 17, 2023

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

Name Status Preview Comments Updated (UTC)
cfbfastr ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 1, 2024 0:36am

Copy link

sweep-ai bot commented Dec 17, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

Signed-off-by: Akshay Easwaran <[email protected]>
Signed-off-by: Akshay Easwaran <[email protected]>
Copy link

coderabbitai bot commented Jan 7, 2024

Walkthrough

The update to the cfbd_betting_lines function in the cfbfastR package enhances the data processing capabilities by addressing the issue of loading betting data for the year 2023. The modifications include advanced string operations and a new data mutation step, improving the function's ability to retrieve and process the desired data.

Changes

File Path Change Summary
R/cfbd_betting.R Updated string manipulation, added a new dplyr mutation, and improved data processing steps.

Assessment against linked issues

Objective Addressed Explanation
#93: Ensure cfbd_betting_lines can load 2023 betting data

Poem

As the code hops along, bugs take flight,
Data once hidden, now gleams in the light.
With strings finely twined and mutations so bright,
The betting lines load, to the coder's delight. 🐰💻🎲

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3fb0e6f and 09ef280.
Files selected for processing (1)
  • R/cfbd_betting.R (2 hunks)
Additional comments: 3
R/cfbd_betting.R (3)
  • 49-49: The addition of stringr::str_replace_all to handle NaN values is a good approach to ensure that the JSON parsing does not fail due to unexpected 'NaN' strings.

  • 140-150: The use of stringr::str_replace_all to replace 'NaN' with 'null' before parsing the JSON response is correct. However, ensure that this replacement does not affect any other unintended parts of the response data.

Verification successful

The verification process has confirmed that the stringr::str_replace_all function is used to replace 'NaN' with 'null' only once in the cfbd_betting.R file. There are no other instances of 'NaN' that could be unintentionally affected by this operation.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that 'NaN' values only occur where they represent missing numeric data and not in other contexts.
rg --type R --glob 'cfbd_betting.R' 'NaN'

Length of output: 65



Script:

#!/bin/bash
# Adjusting the script to search for 'NaN' in 'cfbd_betting.R' without specifying the file type.
rg --glob 'cfbd_betting.R' 'NaN'

Length of output: 101

* 146-149: The mutation using `dplyr::mutate` and `dplyr::case_when` to handle 'null' values in the 'overUnder' column is correctly implemented. It ensures that 'null' strings are converted to `NA_character_`, which is the appropriate NA type for character columns in R.

R/cfbd_betting.R Show resolved Hide resolved
R/cfbd_betting.R Outdated Show resolved Hide resolved
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 09ef280 and 20e06c1.
Files selected for processing (1)
  • R/cfbd_betting.R (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • R/cfbd_betting.R

R/cfbd_betting.R Show resolved Hide resolved
Signed-off-by: Akshay Easwaran <[email protected]>
Copy link

@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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 20e06c1 and 60b1fb2.
Files selected for processing (1)
  • R/cfbd_betting.R (2 hunks)
Additional comments: 3
R/cfbd_betting.R (3)
  • 140-140: The use of stringr::str_replace_all("NaN", 'null') effectively addresses the issue of handling NaN values in the dataset. This change ensures that the JSON parsing does not fail due to NaN values, which are not valid JSON.
  • 145-158: The conditional mutations for overUnder, spread, and formattedSpread using dplyr::case_when are correctly implemented. However, ensure that .data$overUnder, .data$spread, and .data$formattedSpread are correctly referenced on the right-hand side inside the dplyr::case_when, as previously noted by saiemgilani. This ensures that the correct columns are being mutated based on the conditions provided.
  • 160-160: The conditional logic for handling the line_provider parameter and the creation of a default data frame when no data is available or when filtering by line_provider are correctly implemented. The suggestion to refactor the repeated code for creating an empty data frame into a function to avoid duplication and improve maintainability is a good practice. This refactoring makes the code cleaner and more maintainable.

@akeaswaran akeaswaran merged commit a6689e0 into main Feb 1, 2024
5 checks passed
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.

cfbd_betting_lines
2 participants