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

Fix- Upcoming events are not showing in dashboard #98

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

cp-sneha-s
Copy link
Collaborator

@cp-sneha-s cp-sneha-s commented Apr 30, 2024

Purpose

Summary of Changes

Test steps

Conformity

  • Followed git guidelines for creating commit messages and Pull Request guidelines.
  • Self-approved the PR - reviewed the PR as a reviewer and gave it self-approval if everything is ok. If not, made the required changes.
  • Ensured that the PR satisfies all specified requirements in the ticket, including bug fixes and new features.
  • Provided test steps, including steps to reproduce the issue or test the new functionality, ensuring other team members can verify the changes.
  • Added/Updated proper code comments to make it easy-to-understand for other developers.
  • Reused code (if the same code was written twice, made it common and reused it at both places).
  • Removed unused or commented code if not required.
  • Ensured proper Dart naming conventions were used for variables, classes, and methods.
  • Localized user-facing strings.
  • Included screenshots/videos of behavior changes: Provided visual evidence of any changes to UI or behavior for easier review and understanding in the PR description.
  • Implemented proper error handling: Ensured that the code anticipated and handled potential errors and edge cases gracefully.
  • Avoided introducing technical debt: If the PR introduces technical debt, created and linked appropriate tickets for future resolution.
  • Included relevant unit tests: Wrote unit tests that focused on testing behavior and functionality, rather than merely covering lines of code.
  • Ensured code was performant and scalable: Verified that the changes did not introduce performance issues or bottlenecks and could scale as needed.
  • Ensured comments were up-to-date and relevant to the code to describe complex logic and to add understanding for other developers.
  • Marked the PR as ready before submitting it for review.

Visual Evidence (Video, Images or Gif)

Summary by CodeRabbit

  • New Features

    • Added a method to determine if a date is in the current week, enhancing date-related logic.
    • Introduced a new method for formatted representation of event dates.
    • Implemented a new date format in the localization file for improved date display.
  • Style

    • Updated text styling in event cards to reflect different event types dynamically.
  • Documentation

    • Updated test documentation to align with changes in leave management logic.

Copy link

coderabbitai bot commented Apr 30, 2024

Walkthrough

This update enhances date handling and event representation across the application. It includes a refined method for identifying dates within the current week, a new function for formatting event dates, an additional localized date format, stylistic adjustments for event cards based on type, and a modification in the test logic for leave management.

Changes

File Path Change Summary
.../extensions/date_time.dart
.../utils/date_formatter.dart
Updated methods for better date calculations and formatting.
.../l10n/app_en.arb New localized date format added.
.../shared/events/celebrations_event_card.dart Stylistic update for event text based on type.
.../user/leaves/leaves_screen/bloc/leaves/user_leave_bloc_test.dart Updated test logic for grouping leaves.

Poem

🐰✨
In the code, where logic weaves,
A rabbit hops through lines and leaves.
With dates aligned and styles so sleek,
Each update strong, no more the weak.
Celebrate, for changes are chic!
🎉📅


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 1658e67 and 137eb33.
Files selected for processing (5)
  • lib/data/core/extensions/date_time.dart (2 hunks)
  • lib/data/core/utils/date_formatter.dart (3 hunks)
  • lib/data/l10n/app_en.arb (1 hunks)
  • lib/ui/shared/events/celebrations_event_card.dart (1 hunks)
  • test/unit_test/user/leaves/leaves_screen/bloc/leaves/user_leave_bloc_test.dart (1 hunks)
Additional comments not posted (5)
lib/data/core/extensions/date_time.dart (1)

48-48: This utility method is implemented correctly.

lib/data/core/utils/date_formatter.dart (1)

90-97: The new method getEventDateRepresentation is implemented correctly and uses the new date format effectively.

lib/ui/shared/events/celebrations_event_card.dart (1)

183-193: The conditional styling based on the isAnniversary flag in CurrentWeekEventCard is implemented correctly.

test/unit_test/user/leaves/leaves_screen/bloc/leaves/user_leave_bloc_test.dart (1)

140-146: The modification in the test logic to use startDate for grouping leaves aligns with the PR objectives and is implemented correctly.

lib/data/l10n/app_en.arb (1)

179-187: The new date format placeholder "date_format_MMMd" is correctly defined and will aid in presenting dates in a user-friendly format.


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.

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

@cp-sneha-s cp-sneha-s merged commit 1781de2 into main Apr 30, 2024
1 check passed
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.

Actionable comments posted: 1

Comment on lines +20 to +35
bool isDateInCurrentWeek(DateTime currentDate) {
DateTime now = DateTime.now().dateOnly;
DateTime startOfWeek =
now.dateOnly.subtract(Duration(days: now.weekday - 1));
DateTime endOfWeek = startOfWeek.dateOnly
.add(const Duration(days: DateTime.daysPerWeek - 1));

DateTime birthdayThisYear = DateTime(currentDate.year, month, day).dateOnly;
DateTime birthdayNextYear =
DateTime(currentDate.year + 1, month, day).dateOnly;

return (birthdayThisYear.isAfterOrSame(now) &&
birthdayThisYear.isBefore(endOfWeek)) ||
(birthdayNextYear.isAfterOrSame(now) &&
birthdayNextYear.isBefore(endOfWeek));
}
Copy link

Choose a reason for hiding this comment

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

Consider renaming isDateInCurrentWeek to isBirthdayWithinCurrentWeek for better clarity, and add detailed comments explaining the logic.

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.

1 participant