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

bug fix for account summary to Discord #473

Merged
merged 1 commit into from
Jun 16, 2024
Merged

Conversation

grzesir
Copy link
Contributor

@grzesir grzesir commented Jun 14, 2024

No description provided.

Copy link
Contributor

korbit-ai bot commented Jun 14, 2024

My review is in progress 📖 - I will have feedback for you in a few minutes!

Copy link
Contributor

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

I have reviewed your code and found 2 potential issues. To discuss my individual comments that I have added, tag me in replies using @korbit-ai.


Please react with a 👍 to my comments that you find helpful and a 👎 to those you find unhelpful - this will help me learn and improve as we collaborate.

Comment on lines +4174 to +4175
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize(None)
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize("America/New_York", ambiguous='infer')
Copy link
Contributor

Choose a reason for hiding this comment

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

category Readability and Maintainability

The timezone localization can be simplified by combining the operations into a single line. Instead of localizing to None and then to 'America/New_York', you can directly convert the timezone using dt.tz_convert('America/New_York') after ensuring the datetime is localized to UTC. This will make the code more concise and maintainable.

Comment on lines +4169 to +4171
if stats_df['datetime'].dt.tz is None:
# If the datetime is timezone-naive, directly localize it to "America/New_York"
stats_df["datetime"] = stats_df["datetime"].dt.tz_localize("America/New_York", ambiguous='infer')
Copy link
Contributor

Choose a reason for hiding this comment

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

category Objects and Data Structures

I noticed that the datetime handling in the stats_df conversion is not optimal. You're first removing the timezone with tz_localize(None) and then adding it back with tz_localize('America/New_York'). This can be simplified by using tz_convert('America/New_York') directly if the datetime is timezone-aware, or tz_localize('America/New_York') if it is not. Please refactor this to avoid unnecessary steps and potential bugs.

@grzesir grzesir merged commit 6e35154 into dev Jun 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant