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

CV2-5006: fix Sentry issue #1979

Conversation

melsawy
Copy link
Contributor

@melsawy melsawy commented Aug 1, 2024

Description

Fix sentry issue.

References: CV2-5006

How has this been tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can verify the changes. Please describe whether or not you implemented automated tests.

Things to pay attention to during code review

Please describe parts of the change that require extra attention during code review, for example:

  • File FFFF, line LL: This refactoring does this and this. Is it consistent with how it’s implemented elsewhere?
  • Etc.

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I considered secure coding practices when writing this code. Any security concerns are noted above.
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

Copy link
Contributor

@caiosba caiosba left a comment

Choose a reason for hiding this comment

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

@melsawy, I'll follow up in the ticket on why we can't just ignore the cases where the data is not present.

@@ -95,7 +95,7 @@ def number_of_whatsapp_conversations(team_id, start_date, end_date, type = 'all'
all = 0
user = 0
business = 0
data['conversation_analytics']['data'][0]['data_points'].each do |data_point|
data.dig('conversation_analytics', 'data', 0, 'data_points')&.each do |data_point|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@caiosba I suggest to sent a notification in case data_points is nil
i.e
data_points = data.dig('conversation_analytics', 'data', 0, 'data_points')
send_notification if data_points.nil?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK! Let's add details to the ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@caiosba I see that the message that I should add will be close to the Sentry error so I keep raising error for nil data be removing &.each do |data_point| and iterate data without &.

@melsawy melsawy requested a review from caiosba August 5, 2024 04:00
@@ -95,7 +95,7 @@ def number_of_whatsapp_conversations(team_id, start_date, end_date, type = 'all'
all = 0
user = 0
business = 0
data['conversation_analytics']['data'][0]['data_points'].each do |data_point|
data.dig('conversation_analytics', 'data', 0, 'data_points').each do |data_point|
Copy link
Contributor

Choose a reason for hiding this comment

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

@melsawy, if we make this change, what is going to trigger this line? -> https://github.com/meedan/check-api/blob/develop/lib/check_statistics.rb#L115. My suggestion would be to raise an exception if that array is empty but the workspace has TiplineMessage's for the month.

Copy link
Contributor Author

@melsawy melsawy Aug 5, 2024

Choose a reason for hiding this comment

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

@caiosba this line https://github.com/meedan/check-api/blob/develop/lib/check_statistics.rb#L115 will trigger due to using each for nil class so expected this error undefined method each' for nil:NilClass`
I do not recommend to do extra queries so we can close this PR as keep things as it what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, better to keep it as is, then.

@melsawy melsawy closed this Aug 5, 2024
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.

2 participants