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

Timezone in App #2581

Merged
merged 11 commits into from
Oct 14, 2024
Merged

Conversation

pranshugupta54
Copy link
Member

@pranshugupta54 pranshugupta54 commented Oct 10, 2024

What kind of change does this PR introduce?

Feature: timezone

Issue Number:

Fixes #2558

Did you add tests for your changes?

yes

Summary

Solution: Instead of making significant changes to the Mobile/API repositories, I modified how the GraphQL API interacts with Apollo. Now, we're using middleware to handle time conversions: function converts UTC to the local time zone during queries, and function converts local time back to UTC during mutations.

Alternative Approach: I initially spent a lot of time on a different approach that we had discussed and planned earlier according to our issue and project planning. We had planned to change the database by introducing a timezone field and then saving data based on the organization. However, since we don't intend to give users the option to switch timezones like Google Calendar, we can directly modify the API requests and responses to implement this.

Does this PR introduce a breaking change?

NO

Other information

NA

Have you read the contributing guide?

Yes

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced utility functions for comprehensive date and time conversions, enhancing data handling across the application.
    • Enhanced date conversion logic in GraphQL operations for better date management.
    • Improved event creation time formatting for accurate representation.
  • Bug Fixes

    • Enhanced error handling in volunteer group fetching to manage exceptions more effectively.
  • Tests

    • Added a new test suite for time conversion utilities to validate functionality and ensure reliability.
    • Expanded test coverage for the EventService with new tests for volunteer group management, including creation, removal, and updates.

Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The pull request introduces significant changes to the handling of date and time within the GraphQL operations of the application. It adds new utility functions for date-time conversions, modifies existing methods to incorporate these conversions, and updates the CreateEventViewModel to adjust time formatting. Additionally, it includes a new test suite for validating the functionality of the time conversion utilities.

Changes

File Path Change Summary
lib/services/database_mutation_functions.dart Added imports and updated gqlAuthQuery, gqlAuthMutation, gqlNonAuthQuery, and gqlNonAuthMutation methods to include date conversion logic.
lib/utils/time_conversion.dart Introduced utility functions for date-time conversion and a constant map for field definitions.
lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart Modified createEvent method to change time formatting by removing 'Z' suffix from time strings.
test/widget_tests/after_auth_screens/events/time_conversion_test.dart Added a test suite for validating time conversion utilities with multiple test cases.
pubspec.yaml Removed several unused dependencies and added a new dependency clock: ^1.1.1.

Assessment against linked issues

Objective Addressed Explanation
Convert all UTC time from DB to client for queries (#2558)
Convert all local to UTC time for mutations (#2558)

Possibly related PRs

  • Volunteer Management(GSoC) #2567: The changes in this PR involve modifications to the DataBaseMutationFunctions class, particularly in how GraphQL queries and mutations are structured, which aligns with the updates made in the main PR regarding date conversions in those same methods.

Suggested reviewers

  • palisadoes

🐰 In the garden where the time does flow,
Dates and times in harmony, oh what a show!
With queries and mutations, we dance and play,
Converting the hours, come join the fray!
From UTC to local, we hop with glee,
In our time conversion world, come see! 🌼


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 32a42cc and 7f0d55d.

📒 Files selected for processing (1)
  • lib/services/database_mutation_functions.dart (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/services/database_mutation_functions.dart

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.

Copy link

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if either of these two conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

Other

🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.

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: 17

🧹 Outside diff range and nitpick comments (3)
test/widget_tests/after_auth_screens/events/time_conversion_test.dart (2)

17-19: Consider adding more test cases for combineDateTime

While the current test case verifies the basic functionality of combineDateTime, consider adding more test cases to cover edge cases and different input formats. This could include:

  1. Combining date and time with different formats (e.g., AM/PM time)
  2. Handling of invalid inputs
  3. Behavior with extreme date/time values

Example:

test('combineDateTime handles various input formats', () {
  expect(combineDateTime('2023-05-01', '02:30:00 PM'), '2023-05-01 14:30:00');
  expect(combineDateTime('2023-12-31', '23:59:59'), '2023-12-31 23:59:59');
  // Add more assertions for edge cases
});

21-31: Enhance datetime splitting tests and fix local time format

  1. Consider adding more test cases for splitDateTimeUTC and splitDateTimeLocal to cover various scenarios, including edge cases and different input formats.

  2. In the splitDateTimeLocal test, the expected time format seems inconsistent with the UTC test. The local time is expected to be in "HH:mm" format, while the UTC time includes seconds and milliseconds. Ensure this is the intended behavior.

Example of additional test cases:

test('splitDateTimeUTC handles various input formats', () {
  expect(splitDateTimeUTC('2023-12-31T23:59:59.999Z'), {'date': '2023-12-31', 'time': '23:59:59.999Z'});
  // Add more assertions for edge cases
});

test('splitDateTimeLocal handles various input formats', () {
  expect(splitDateTimeLocal('2023-12-31T23:59:59.999'), {'date': '2023-12-31', 'time': '23:59'});
  // Add more assertions for edge cases
});
lib/utils/time_conversion.dart (1)

3-5: Consider validating input in combineDateTime

The combineDateTime function concatenates date and time without validation. If either parameter is empty or improperly formatted, it may lead to issues downstream. Consider adding validation or formatting to ensure the combined string is a valid date-time.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6be82c3 and fcc0c38.

📒 Files selected for processing (5)
  • lib/services/database_mutation_functions.dart (5 hunks)
  • lib/services/event_service.dart (1 hunks)
  • lib/utils/time_conversion.dart (1 hunks)
  • lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart (1 hunks)
  • test/widget_tests/after_auth_screens/events/time_conversion_test.dart (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
test/widget_tests/after_auth_screens/events/time_conversion_test.dart (2)

1-15: LGTM: Well-structured test setup

The import statements and the main test structure are well-organized. The use of setUp and tearDown methods for service registration is a good practice for maintaining a clean test environment.


1-108: Overall assessment: Good foundation, room for improvement

The test suite provides a solid foundation for verifying the time conversion utilities. It covers the basic functionality of various conversion methods and handles different data structures. However, there are several opportunities to enhance the test coverage and robustness:

  1. Add more test cases to cover edge cases and different input formats.
  2. Verify the actual conversion logic, not just the output format.
  3. Use fixed timezones and known input/output pairs for more precise testing.
  4. Enhance tests for complex nested structures and lists.
  5. Include tests for error handling and invalid inputs.

Implementing these suggestions will significantly improve the reliability and comprehensiveness of the test suite, ensuring that the time conversion utilities work correctly across various scenarios.

lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart (1)

Line range hint 1-438: Review overall timezone implementation in CreateEventViewModel

The changes in this file are limited to the createEvent method, specifically the formatting of startTime and endTime. While this change aligns with the PR objective of implementing timezone handling, there are a few concerns:

  1. The eventStartTime, eventEndTime, eventStartDate, and eventEndDate properties are not modified to account for timezone differences. Should these be adjusted as well?
  2. The recurrenceStartDate and recurrenceEndDate handling remains unchanged. Do these need to be considered in the timezone implementation?
  3. There's no visible logic for handling user-specific timezone preferences. How is the user's timezone being determined and applied?

To ensure a comprehensive implementation of the timezone feature, consider reviewing these points and adding any necessary logic or comments to clarify the timezone handling approach throughout the CreateEventViewModel class.

To verify the completeness of the timezone implementation, please run the following script:

#!/bin/bash
# Description: Analyze timezone-related code in CreateEventViewModel and related files

# Test 1: Search for timezone-related code in CreateEventViewModel
echo "Searching for timezone-related code in CreateEventViewModel:"
rg --type dart "(?i)timezone|utc|local.*time" lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart

# Test 2: Search for user timezone preference handling
echo "\nSearching for user timezone preference handling:"
rg --type dart "(?i)user.*timezone|timezone.*preference"

# Test 3: Search for date and time parsing in related event files
echo "\nSearching for date and time parsing in related event files:"
rg --type dart "(?i)parse.*time|parse.*date|format.*time|format.*date" lib/view_model/after_auth_view_models/event_view_models/

This script will help us identify any missing pieces in the timezone implementation and ensure that all necessary components are properly handled.

lib/utils/time_conversion.dart (1)

24-24: Verify the date-time format strings

The format strings used in convertUTCToLocal and convertLocalToUTC may not fully align with standard ISO 8601 formats. Ensure that the patterns correctly represent the intended formats, including milliseconds and timezone indicators.

Run the following script to review all DateFormat patterns used:

Also applies to: 29-29

lib/services/database_mutation_functions.dart (3)

9-10: LGTM

The new imports for connectivity_view_model.dart and time_conversion.dart are appropriate and necessary for the added date conversion functionality.


102-103: LGTM

The added code correctly converts dates from UTC to local time in the query results using traverseAndConvertDates. This ensures that all date-time data in queries is consistent with the client's local time.


222-223: LGTM

The added code effectively converts dates from UTC to local time in the query results for non-authenticated queries using traverseAndConvertDates. This maintains consistency in date-time handling across the application.

lib/services/database_mutation_functions.dart Show resolved Hide resolved
lib/services/database_mutation_functions.dart Outdated Show resolved Hide resolved
lib/services/event_service.dart Outdated Show resolved Hide resolved
lib/services/event_service.dart Outdated Show resolved Hide resolved
lib/services/event_service.dart Outdated Show resolved Hide resolved
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/utils/time_conversion.dart (1)

19-19: Consider standardizing time formats for consistency

In splitDateTimeLocal, the time format is 'HH:mm', which includes hours and minutes. In splitDateTimeUTC, the time format is 'HH:mm:ss.SSS\'Z\'', including hours, minutes, seconds, and milliseconds. For consistency, consider including seconds and milliseconds in both local and UTC time formats, or document the reason for the difference.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fcc0c38 and f210aab.

📒 Files selected for processing (4)
  • lib/services/database_mutation_functions.dart (5 hunks)
  • lib/services/event_service.dart (1 hunks)
  • lib/utils/time_conversion.dart (1 hunks)
  • lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/services/database_mutation_functions.dart
  • lib/services/event_service.dart
  • lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart
🧰 Additional context used
🔇 Additional comments (6)
lib/utils/time_conversion.dart (6)

8-8: Add error handling for date parsing in splitDateTimeUTC


16-16: Add error handling for date parsing in splitDateTimeLocal


24-24: Add error handling for date parsing in convertUTCToLocal


29-29: Add error handling for date parsing in convertLocalToUTC


45-46: Ensure safe casting of date and time fields


61-61: Handle non-string values in directFields conversion

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 10, 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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f210aab and d7ab113.

⛔ Files ignored due to path filters (1)
  • pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • lib/services/database_mutation_functions.dart (5 hunks)
  • lib/utils/time_conversion.dart (1 hunks)
  • lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart (1 hunks)
  • pubspec.yaml (1 hunks)
  • test/widget_tests/after_auth_screens/events/time_conversion_test.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/services/database_mutation_functions.dart
  • lib/utils/time_conversion.dart
  • lib/view_model/after_auth_view_models/event_view_models/create_event_view_model.dart
  • test/widget_tests/after_auth_screens/events/time_conversion_test.dart
🧰 Additional context used
🔇 Additional comments (2)
pubspec.yaml (2)

24-24: Excellent addition of the clock package for timezone handling.

The addition of clock: ^1.1.1 is a great choice for implementing timezone features. This package allows for easy mocking of the system clock, which will be invaluable for testing time-dependent code, especially when dealing with different timezones.

Consider utilizing this package in your tests to ensure the robustness of your timezone conversion logic across various scenarios.


Line range hint 18-23: Verify the intention behind removing analysis and linting dependencies.

The following dependencies have been removed or commented out:

  • _fe_analyzer_shared: ^60.0.0
  • analyzer
  • analyzer_plugin
  • custom_lint_builder: ^0.4.0

While these removals don't directly impact the timezone feature implementation, they are typically used for static analysis and linting. Removing them might affect code quality checks. Can you confirm if this was intentional and if there are alternative tools in place for maintaining code quality?

Also applies to: 32-34

✅ Verification successful

Linting and analysis dependencies have been appropriately updated.

The removal of older linting tools has been effectively replaced by the addition of custom_lint, lint, and talawa_lint. This ensures that code quality checks are maintained with up-to-date tools.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there are any remaining linting or analysis tools
rg --type yaml 'lint|analyzer' pubspec.yaml

Length of output: 219

pubspec.yaml Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.46%. Comparing base (4e11f1b) to head (4cc8ab5).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2581      +/-   ##
===========================================
+ Coverage    96.45%   96.46%   +0.01%     
===========================================
  Files          179      180       +1     
  Lines         9191     9227      +36     
===========================================
+ Hits          8865     8901      +36     
  Misses         326      326              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 (4)
test/service_tests/event_service_test.dart (4)

Line range hint 255-292: Add error handling for null or unexpected responses

In the Test createVolunteerGroup method, consider adding assertions to handle cases where the response data might be null or missing expected fields. This will make the test more robust against unexpected API responses.


Line range hint 255-338: Refactor duplicate setup code in test methods

Multiple test methods have duplicated setup code for dataBaseMutationFunctions, query, and instantiation of EventService. To adhere to the DRY principle and improve maintainability, consider extracting common setup steps into a setUp method provided by the test package.


Line range hint 255-338: Enhance test coverage with edge cases

The newly added tests focus on successful executions. To improve test coverage, consider adding tests for edge cases such as:

  • API returning error responses
  • Unexpected data formats
  • Exception handling when inputs are invalid

This ensures the methods behave correctly under all circumstances.


Line range hint 255-338: Simplify unnecessary casting in test assertions

In your test assertions, you're casting result to QueryResult even though it is already of that type. This casting is unnecessary and can be removed to simplify the code.

Apply this diff to remove unnecessary casts:

 expect(result, isNotNull);
- expect(
-   (result as QueryResult).data!['createVolunteerGroup']['_id'],
+ expect(
+   result.data!['createVolunteerGroup']['_id'],
    'groupId1',
 );
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d7ab113 and 32a42cc.

📒 Files selected for processing (1)
  • test/service_tests/event_service_test.dart (4 hunks)
🧰 Additional context used
🔇 Additional comments (4)
test/service_tests/event_service_test.dart (4)

122-122: Corrected typo in 'createdEvent' key

Good job fixing the typo from 'cretedEvent' to 'createdEvent', ensuring the test checks the correct response key.


141-141: Variables map now includes 'eventId'

Including 'eventId' in the variables map for the registerForAnEvent test ensures that the mutation receives the necessary parameter, enhancing test accuracy.


147-147: Updated response key to 'registerForEvent'

The response data now correctly uses the 'registerForEvent' key, matching the expected mutation response.


Line range hint 255-292: Verify variable structure matches GraphQL mutation requirements

In the createVolunteerGroup test, ensure that the variables structure aligns with what the GraphQL mutation expects. The current structure uses variables: {'data': variables}. Confirm that 'data' is the correct key expected by the backend.

Run the following script to check the expected variable structure in the GraphQL schema:

✅ Verification successful

Verified: The variables structure in the createVolunteerGroup test correctly uses the 'data' key as expected by the GraphQL mutation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the expected input structure for createVolunteerGroup mutation.

# Test: Search for the createVolunteerGroup mutation definition. Expect: The correct variable structure.
rg --type graphql 'mutation.*createVolunteerGroup' -A 10

Length of output: 90


Script:

#!/bin/bash
# Description: Verify the expected input structure for createVolunteerGroup mutation across all relevant files.

# Search for the createVolunteerGroup mutation definition in Dart files.
rg 'mutation\s+createVolunteerGroup' --type dart -A 10

Length of output: 56


Script:

#!/bin/bash
# Description: Broadly search for the createVolunteerGroup mutation definition across all files.

# Search for the createVolunteerGroup mutation in all files.
rg 'createVolunteerGroup' -A 10

Length of output: 24329

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 10, 2024
@palisadoes
Copy link
Contributor

@pranshugupta54

Please try to get the code coverage up so that the tests pass.

@palisadoes
Copy link
Contributor

  1. Does the mobile client use the local timezone when doing it's datetime calculations?
  2. Is this true for the changes you made to talawa-admin?

@pranshugupta54
Copy link
Member Author

@palisadoes

Please try to get the code coverage up so that the tests pass.

The coverage is low mainly due to changes in [lib/services/event_service.dart] file which was actually a part of different issue. @Dante291 helped me fix it as this issue was blocking me so he'll add the tests for it in his PR.

I will be adding lines ignore for the some lines in [lib/services/database_mutation_functions.dart] because we won't be doing timezone tests for mock as we discussed earlier. (Mocks are static data so if we add tests for it then we'll need different test-mocks for each and every timezone)

Does the mobile client use the local timezone when doing it's datetime calculations?
Is this true for the changes you made to talawa-admin?

Yes, it's similar to Talawa-Admin. Now it's a middleware to change the time. I've tested this and now whenever I make a new event using IST time then it converts and saves in UTC in database, and at the time of viewing any event - it automatically converts back to IST (my local time) from UTC. So, for a user it's always shown in local time for them, but we store in UTC in database.

@Dante291
Copy link
Contributor

@palisadoes

Please try to get the code coverage up so that the tests pass.

The coverage is low mainly due to changes in [lib/services/event_service.dart] file which was actually a part of different issue. @Dante291 helped me fix it as this issue was blocking me so he'll add the tests for it in his PR.

I will be adding lines ignore for the some lines in [lib/services/database_mutation_functions.dart] because we won't be doing timezone tests for mock as we discussed earlier. (Mocks are static data so if we add tests for it then we'll need different test-mocks for each and every timezone)

Does the mobile client use the local timezone when doing it's datetime calculations?
Is this true for the changes you made to talawa-admin?

Yes, it's similar to Talawa-Admin. Now it's a middleware to change the time. I've tested this and now whenever I make a new event using IST time then it converts and saves in UTC in database, and at the time of viewing any event - it automatically converts back to IST (my local time) from UTC. So, for a user it's always shown in local time for them, but we store in UTC in database.

Just dont make these changes in your PR, I will do that in mine and add tests too

@Dante291
Copy link
Contributor

also please attach a clip of app working properly after making these changes to ensure proper working

@pranshugupta54
Copy link
Member Author

Event creation in local time:
https://github.com/user-attachments/assets/01fde012-b66d-4bbe-b245-f74f6e43cd49

Saved in UTC in database:
Screenshot 2024-10-13 at 7 18 35 PM

@palisadoes
Copy link
Contributor

@noman2002 PTAL.

The aim is for the mobile app to interact with the API only using UTC times. This will help with converting calendar entries to the correct local time when the end user could be in a different timezone from the client.

Work in Admin and API has already been completed

Copy link
Member

@noman2002 noman2002 left a comment

Choose a reason for hiding this comment

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

LGTM, good work @pranshugupta54 .

@palisadoes palisadoes merged commit b5d02c4 into PalisadoesFoundation:develop Oct 14, 2024
10 of 11 checks passed
@Dante291
Copy link
Contributor

@palisadoes @pranshugupta54 This PR breaks the app, no server call are successful after this got merged. need to revert it.

@pranshugupta54
Copy link
Member Author

@Dante291, did you try making the changes in that event file. This PR won't work without those changes.

@Dante291
Copy link
Contributor

Dante291 commented Oct 14, 2024

@Dante291, did you try making the changes in that event file. This PR won't work without those changes.

Yup I did that, also those changes were related to event service only so even if anything breaks if some error is occurring due to that, it should be only related to events, but after this got merged neither user data is loading nor the posts, basically nothing.

@pranshugupta54
Copy link
Member Author

I tried running it, looks good to me.
I'm able to make changes to my profile and it does reflect in DB.

Let's discuss this on Slack first and if there is some issue then we can fix it.

@pranshugupta54
Copy link
Member Author

pranshugupta54 commented Oct 14, 2024

Looks like some issues due to unhandled catch blocks.

Quick Fix: #2592

cc: @palisadoes

@coderabbitai coderabbitai bot mentioned this pull request Oct 14, 2024
@palisadoes
Copy link
Contributor

It's merged

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.

Timezone Middleware with Apollo
4 participants