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

651-fix: Incorrect course date on course page #652

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

Quiddlee
Copy link
Member

@Quiddlee Quiddlee commented Nov 15, 2024

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

Related Tickets & Documents

Screenshots, Recordings

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

gif

Summary by CodeRabbit

  • New Features

    • Enhanced course availability logic with dynamic stale period adjustment.
    • Streamlined date handling in the HeroCourse component for improved performance.
  • Bug Fixes

    • Removed outdated import statements and unused functions for cleaner code.
  • Refactor

    • Updated method signatures for better flexibility in course status calculations.

@github-actions github-actions bot changed the title fix: 651 - courses stale data on course page 651-fix: Incorrect course date on course page Nov 15, 2024
@Quiddlee Quiddlee self-assigned this Nov 15, 2024
@Quiddlee Quiddlee added bug Something isn't working high priority labels Nov 15, 2024
Copy link

Lighthouse Report:

  • Performance: 81 / 100
  • Accessibility: 99 / 100
  • Best Practices: 100 / 100
  • SEO: 100 / 100

View detailed report

@Quiddlee Quiddlee marked this pull request as ready for review November 22, 2024 14:54
Copy link
Contributor

coderabbitai bot commented Nov 22, 2024

πŸ“ Walkthrough

Walkthrough

The pull request introduces modifications to the getCourseStatus function by adding a new parameter, courseStaleAfterDays, which enhances the flexibility of course availability calculations. Additionally, changes to the HeroCourse component streamline date handling by using dayJS for date differences, eliminating the need for previously defined constants. These updates collectively refine how course statuses are determined based on registration and start dates.

Changes

File Path Change Summary
src/widgets/hero-course/helpers/get-course-status.ts Updated getCourseStatus function to include a new parameter courseStaleAfterDays.
src/widgets/hero-course/ui/hero-course.tsx Modified HeroCourse component to use dayJS for date calculations and adjusted getCourseStatus call accordingly.

Assessment against linked issues

Objective Addressed Explanation
Fix incorrect course date on course page (#651) βœ…

Possibly related PRs

Suggested reviewers

  • andron13
  • dzmitry-varabei
  • natanchik
  • SpaNb4

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

πŸ”§ eslint (1.23.1)

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/widgets/hero-course/helpers/get-course-status.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-boundaries".

(The package "eslint-plugin-boundaries" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-boundaries@latest --save-dev

The plugin "eslint-plugin-boundaries" was referenced from the config file in " Β» @feature-sliced/eslint-config Β» /node_modules/@feature-sliced/eslint-config/rules/layers-slices".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


πŸ“œ Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 15835e5 and 94ce3aa.

πŸ“’ Files selected for processing (2)
  • src/widgets/hero-course/helpers/get-course-status.ts (1 hunks)
  • src/widgets/hero-course/ui/hero-course.tsx (3 hunks)
πŸ”‡ Additional comments (5)
src/widgets/hero-course/helpers/get-course-status.ts (2)

7-10: LGTM! Clean function signature update.

The optional parameter with default value maintains backward compatibility while adding flexibility.


18-19: Verify the date window calculation.

The symmetric date window calculation looks correct, but let's verify that this change fixes the reported issue with incorrect course dates.

βœ… Verification successful

Date window calculation is consistent across the codebase

The date window calculation in get-course-status.ts aligns with other date-related calculations in the codebase:

  • getCourseDate.ts uses the same subtract operation with days
  • Test files confirm the stale date logic with consistent day-based calculations
  • COURSE_STALE_AFTER_DAYS is properly defined as 14 days in core/const/index.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any other date-related calculations in the codebase that might need similar updates

# Look for similar date window calculations
rg -A 2 "subtract\(.*,\s*['\"](day|days)['\"]" 

# Look for other usages of COURSE_STALE_AFTER_DAYS
rg "COURSE_STALE_AFTER_DAYS"

Length of output: 1319

src/widgets/hero-course/ui/hero-course.tsx (3)

5-5: LGTM: Clean import addition

The dayJS import follows the project's conventions and supports the new date calculation approach.


Line range hint 36-40: LGTM: Simplified date handling

The direct usage of startDate improves code clarity by removing unnecessary intermediate variables.


25-25: Verify consistent usage of dynamic course status calculation

The new approach using dynamic date difference calculation is more flexible, but we should ensure it's consistently implemented across the codebase.

βœ… Verification successful

The dynamic calculation is correctly implemented

The change is consistent with the getCourseStatus implementation. The function accepts an optional courseStaleAfterDays parameter which defaults to COURSE_STALE_AFTER_DAYS constant, making the new dynamic calculation a valid usage pattern.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other getCourseStatus usages to ensure consistent implementation
ast-grep --pattern 'getCourseStatus($_)'

Length of output: 280


Script:

#!/bin/bash
# Let's check the implementation and usage context
ast-grep --pattern 'function getCourseStatus($_) { $$$ }'

# Also check the test file content
cat src/widgets/hero-course/helpers/get-course-status.test.ts

Length of output: 1131


Script:

#!/bin/bash
# Let's check the implementation of getCourseStatus
cat src/widgets/hero-course/helpers/get-course-status.ts

Length of output: 1224


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.

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.

@Quiddlee Quiddlee merged commit b7c52eb into main Nov 22, 2024
5 of 7 checks passed
@Quiddlee Quiddlee deleted the fix/651-incorrect-course-date-on-course-page branch November 22, 2024 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix incorrect course date on course page
3 participants