-
Notifications
You must be signed in to change notification settings - Fork 11
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-2648 Refactor Tipline requests #1743
CV2-2648 Refactor Tipline requests #1743
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Sawy! Getting there!
conditions = { | ||
created_at: start_date..end_date, | ||
team_id: team_id, | ||
language: language, | ||
platform: platform | ||
} | ||
conditions[:smooch_request_type] = type unless type.nil? | ||
TiplineRequest.where(conditions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way cleaner!
times << (f.created_at - f.annotation.created_at) | ||
reports_received(team_id, platform, start_date, end_date, language).find_each do |tr| | ||
# TODO: review with Caio | ||
times << (tr.updated_at - tr.created_at) | ||
end | ||
median_response_time_in_seconds = times.size == 0 ? nil : times.sum.to_f / times.size | ||
statistics[:median_response_time] = median_response_time_in_seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of the changes here look good, but please run the rake task to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melsawy , did you run the rake task?
t.string :language, index: true | ||
t.string :tipline_user_uid, index: true | ||
t.string :platform, index: true | ||
t.text :smooch_request_type, null: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Request type can't be null.
lib/check_statistics.rb
Outdated
@@ -16,7 +16,7 @@ def requests(team_id, platform, start_date, end_date, language, type = nil) | |||
def reports_received(team_id, platform, start_date, end_date, language) | |||
TiplineRequest | |||
.where(team_id: team_id, language: language, created_at: start_date..end_date, platform: platform) | |||
.where('smooch_report_received_at IS NOT NULL') | |||
.where.not(smooch_report_received_at: 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can still be NULL
, no? I think it's more robust to change this condition to:
.where('smooch_report_received_at > 0')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No as I set the default value to 0
in migration file so it'll be a value or 0
times << (f.created_at - f.annotation.created_at) | ||
reports_received(team_id, platform, start_date, end_date, language).find_each do |tr| | ||
# TODO: review with Caio | ||
times << (tr.updated_at - tr.created_at) | ||
end | ||
median_response_time_in_seconds = times.size == 0 ? nil : times.sum.to_f / times.size | ||
statistics[:median_response_time] = median_response_time_in_seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melsawy , did you run the rake task?
@@ -0,0 +1,220 @@ | |||
namespace :check do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document here (as a comment, first line of the file) how to call the rake tasks (expected args, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already I added a line before rake task definition bundle exec rails check:migrate:migrate_tipline_requests
test/models/bot/smooch_8_test.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this file was deleted? No more useful tests here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this file contains only one test and no more useful
test/test_helper.rb
Outdated
@@ -159,7 +159,8 @@ def before_all | |||
# This will run before any test | |||
|
|||
def setup | |||
[Account, Media, ProjectMedia, User, Source, Annotation, Team, TeamUser, Relationship, Project, TiplineResource].each{ |klass| klass.delete_all } | |||
puts "[Starting test #{self.class.name}::#{self.method_name}]" # Output which test has started running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/test_helper.rb
Outdated
@@ -195,6 +196,7 @@ def setup | |||
# This will run after any test | |||
|
|||
def teardown | |||
puts "[Finishing test #{self.class.name}::#{self.method_name}]" # Output which test has finished running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please comment this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…com:meedan/check-api into refactor/CV2-2648-refactor-tipline-requests
@caiosba I applied latest comments and asked @sonoransun for a recent live dump so I can verify tipline refactor rake task and statistic rake task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @melsawy - please re-request my review once the other issues are fixed too (see testing sheet).
@caiosba please review the latest changes and please verify rake tasks on your local machine
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@melsawy , I just reviewed the latest changes to the PR and tested the migration and statistic rake tasks locally. All good except for one thing: the “average time for publishing” data point is not being calculated correctly (or maybe the data points involved were not migrated correctly?). More details in Jira.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sawy, it still doesn't work. I added more details to the Jira ticket.
…com:meedan/check-api into refactor/CV2-2648-refactor-tipline-requests
Code Climate has analyzed commit 69b6f16 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 100.0% (100% is the threshold). This pull request will bring the total coverage in the repository to 100.0% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @melsawy , the statistics rake task works for me now.
Description
Convert smooch annotations to a new model
TiplineRequest
through the following steps:References: CV2-2648
How has this been tested?
Fix existing tests and make sure travis tests passed.
Run tipline integration locally
Things to pay attention to during code review
Please describe parts of the change that require extra attention during code review, for example:
Checklist