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

Feature: Measure time spent playing from the start and round up in minutes (KIDS-1525) #1161

Merged

Conversation

TammiLion
Copy link
Contributor

@TammiLion TammiLion commented Oct 11, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced accuracy in time tracking for game sessions.
  • Bug Fixes

    • Removed the time tracking functionality during the interview process.
  • Improvements

    • Updated calculation method for total minutes played, now based on seconds for increased precision.
    • Introduced new timing management variables for better tracking of game session durations.

@TammiLion TammiLion requested a review from a team as a code owner October 11, 2024 09:44
Copy link
Contributor

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes involve the removal of the increaseTimeSpent method from the InterviewCubit class, which eliminates the functionality for tracking time spent during interviews. Additionally, the SummaryCubit class has modified its init method to calculate total minutes played using a new variable, totalTimeSpentInSeconds. The ReflectAndShareRepository class has seen variable renaming and the introduction of new private variables for better time management. Lastly, the call to increaseTimeSpent has been removed from the RecordAnswerScreen class, affecting the countdown logic.

Changes

File Path Change Summary
lib/features/family/features/reflect/bloc/interview_cubit.dart Removed method: void increaseTimeSpent()
lib/features/family/features/reflect/bloc/summary_cubit.dart Updated init method to calculate totalMinutesPlayed using totalTimeSpentInSeconds
lib/features/family/features/reflect/domain/reflect_and_share_repository.dart Renamed variable: totalTimeSpent to totalTimeSpentInSeconds; added _startTime and _endTime; updated saveSummaryStats and selectProfiles methods for new time management.
lib/features/family/features/reflect/presentation/pages/record_answer_screen.dart Removed call to cubit.increaseTimeSpent(); from _startCountdown method

Assessment against linked issues

Objective Addressed Explanation
Start tracking time from first playing gratitude game to stop tracking at summary screen (KIDS-1525) The removal of increaseTimeSpent prevents tracking from start to finish.
Always round up the number so 7mins 20 seconds would be 8 minutes (KIDS-1525) The SummaryCubit now applies a ceiling function to the time calculation.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • Daniela510
  • MaikelStuivenberg

Poem

In the burrow where time does play,
The rabbits hop and bounce all day.
With changes made, we track anew,
Counting moments, just me and you!
So let the minutes round and cheer,
For every second spent, we hold dear! 🐇✨


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.

@github-actions github-actions bot added the enhancement New feature or request label Oct 11, 2024
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 and nitpick comments (1)
lib/features/family/features/reflect/domain/reflect_and_share_repository.dart (1)

36-38: Implement rounding up to nearest minute

The calculation of totalTimeSpentInSeconds accurately tracks the total time spent playing. However, to fully meet the PR objectives, we should round up this value to the nearest minute.

Consider modifying the calculation as follows:

-      totalTimeSpentInSeconds = _endTime!.difference(_startTime!).inSeconds;
+      totalTimeSpentInSeconds = (_endTime!.difference(_startTime!).inSeconds / 60).ceil() * 60;

This change will round up the time to the nearest minute, ensuring that partial minutes are accounted for as specified in the PR objectives.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 814d386 and 21df3ed.

📒 Files selected for processing (4)
  • lib/features/family/features/reflect/bloc/interview_cubit.dart (0 hunks)
  • lib/features/family/features/reflect/bloc/summary_cubit.dart (1 hunks)
  • lib/features/family/features/reflect/domain/reflect_and_share_repository.dart (3 hunks)
  • lib/features/family/features/reflect/presentation/pages/record_answer_screen.dart (0 hunks)
💤 Files with no reviewable changes (2)
  • lib/features/family/features/reflect/bloc/interview_cubit.dart
  • lib/features/family/features/reflect/presentation/pages/record_answer_screen.dart
🧰 Additional context used
🔇 Additional comments (4)
lib/features/family/features/reflect/bloc/summary_cubit.dart (1)

14-15: LGTM! Changes align well with PR objectives.

The modification to calculate totalMinutesPlayed effectively implements the required features:

  1. It uses totalTimeSpentInSeconds, which likely represents the total time from game start, addressing the need to measure the entire gameplay duration.
  2. The division by 60 correctly converts seconds to minutes.
  3. The use of ceil() ensures rounding up to the nearest minute, fulfilling the requirement to round up partial minutes.

These changes accurately reflect the PR objectives of measuring time from the start of the game and rounding up to the nearest minute.

lib/features/family/features/reflect/domain/reflect_and_share_repository.dart (3)

18-20: LGTM: Improved time tracking variables

The renaming of totalTimeSpent to totalTimeSpentInSeconds and the addition of _startTime and _endTime variables align well with the PR objective of measuring the total time spent playing from the start of the game. These changes provide a solid foundation for more accurate time tracking.


89-89: LGTM: Resetting time for new game sessions

Resetting totalTimeSpentInSeconds to 0 when selecting profiles ensures that each new game session starts with a clean slate for time tracking. This aligns well with the PR objective of measuring time from the start of each game.


90-90: Ensure end time is set when game concludes

Setting _startTime at the beginning of the game session is correct and aligns with the PR objective. However, to complete the time tracking implementation:

  1. Ensure that _endTime is set when the game concludes, possibly in a method that handles the end of the game or when reaching the summary screen.
  2. Verify that saveSummaryStats() is called at the appropriate time to calculate and save the total time spent.

To help verify this, you can run the following script:

This will help ensure that the time tracking is fully implemented as per the PR objectives.

✅ Verification successful

✅ Time Tracking Implementation Verified

The _endTime is properly set in reflect_and_share_repository.dart, and saveSummaryStats() is called in both reflect_and_share_repository.dart and summary_cubit.dart. Time tracking is fully implemented as per the PR objectives.

  • reflect_and_share_repository.dart: _endTime = DateTime.now();
  • summary_cubit.dart: _reflectAndShareRepository.saveSummaryStats();
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for _endTime setting and saveSummaryStats() call

# Search for potential locations where _endTime might be set
echo "Potential _endTime setting locations:"
rg --type dart "_endTime\s*=\s*DateTime\.now\(\)" ./lib

# Search for saveSummaryStats() calls
echo "\nLocations where saveSummaryStats() is called:"
rg --type dart "saveSummaryStats\(\)" ./lib

Length of output: 628

@TammiLion TammiLion merged commit ffb99fb into develop Oct 11, 2024
1 check passed
@TammiLion TammiLion deleted the feature/kids-1525-measure-time-playing-from-start branch October 11, 2024 10:35
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants