-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Limit reviews upto date specified. #13040
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
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 for making this PR 😊 I probably left too many comments but date stuff is weird 😊
BTW, we probably also want to filter all_reviews
with the up to the date specified in the parameter. Right now the date logic is only breaking the loop but not filtering the any that may actually be before the date 🙃
@@ -371,6 +371,12 @@ def get_reviews(app_id, platform, storefront, version_id) | |||
|
|||
r = request(:get, rating_url) | |||
all_reviews.concat(parse_response(r, 'data')['reviews']) | |||
|
|||
last_review_date = Date.parse(Time.at(all_reviews[-1]['value']['lastModified']/1000).to_s).to_date | |||
if last_review_date < DateTime.parse(upto_date).to_date |
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.
Can we move the DateTime.parse(upto_date).to_date
to a variable before the loop do
so that this operation oly needs to happen once 😊
Also, we should be able to just use Time.parse
and then remove the Date.parse
on line 375 (see comment on 375)
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.
@@ -46,8 +46,8 @@ def average_rating | |||
end | |||
|
|||
# @return (Array) of Review Objects | |||
def reviews(store_front = '', version_id = '') | |||
raw_reviews = client.get_reviews(application.apple_id, application.platform, store_front, version_id) | |||
def reviews(store_front = '', version_id = '', upto_date = '') |
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.
Can we make upto_date = ''
default to nil
instead?
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.
Good idea. Done! e846dd1#diff-ba47141cdb85eda8d52ad6ea553966fb
@@ -371,6 +371,12 @@ def get_reviews(app_id, platform, storefront, version_id) | |||
|
|||
r = request(:get, rating_url) | |||
all_reviews.concat(parse_response(r, 'data')['reviews']) | |||
|
|||
last_review_date = Date.parse(Time.at(all_reviews[-1]['value']['lastModified']/1000).to_s).to_date |
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.
We should be able to just do Time.at(all_reviews[-1]['value']['lastModified']/1000)
and compare on time (see comment below)
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! e846dd1#diff-64843dee7bf6cf0342bd0e57d9b43c2b
Please take a look and let me know if you'd like to change it to something else.
@@ -358,7 +358,7 @@ def get_ratings(app_id, platform, version_id = '', storefront = '') | |||
parse_response(r, 'data') | |||
end | |||
|
|||
def get_reviews(app_id, platform, storefront, version_id) | |||
def get_reviews(app_id, platform, storefront, version_id, upto_date) |
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.
Can you change this upto_date
to default to nil
like upto_date = nil
to make this backwards compatible? There will need to be an if check below in the logic to check to make sure this upto_date
isn't nil
then but that logic is okay to have in 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.
@joshdholtz Have made changes suggested by you! Kindly take a look and let me know if you need me to do anything else. |
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.
Got a few more small comments! It also looks like the tests are failing and so is the linting. So if you could also ...
- Fix existing tests
- Add new tests that use the new parameter
- Run rubocop (the linter) by running
rubocop -a && rubocop -D
- Sign CLA
Looking forward to getting this merged after these steps 😊
@@ -371,13 +374,20 @@ def get_reviews(app_id, platform, storefront, version_id) | |||
|
|||
r = request(:get, rating_url) | |||
all_reviews.concat(parse_response(r, 'data')['reviews']) | |||
last_review_date = Time.at(all_reviews[-1]['value']['lastModified']/1000) | |||
|
|||
break if last_review_date < upto_date && !upto_date.nil? |
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 would probably make this break and filter here something like this...
if upto_date && last_review_date < upto_date
all_reviews = all_reviews.select { |review| Time.at(review['value']['lastModified']/1000) > upto_date }
break
end
And then remove the multiple returns at the bottom
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.
haha cool. I originally had something similar to this, but then I thought I should keep it a one-liner (looked at a couple of other break
statements). Changed it to like you suggested!
7c572e2
|
||
return all_reviews if upto_date.nil? | ||
|
||
return all_reviews.select { |review| Time.at(review['value']['lastModified']/1000) > upto_date } |
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.
Remove these multiple return
s and just do... (see above comment)
return all_reviews
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! :)
@joshdholtz I will add tests tomorrow and look into fixing the linting as well! |
@scorpion35 Sounds great! Just ping me when its ready for a review again 😊 |
Branch: "reviews_uptodate" | Commit Type: "Bug fix" | Changes tested: "no"
I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
I signed it! |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
@joshdholtz Fixed the linting test. I have also signed the CLA. I tried to write new tests, but couldn't seem to figure it out. c57e713 & ee69cfe Could you give me some guidance on how to make a new test, please? I have tried to place a |
@scorpion35 Yup, I can help! I'm not sure if I'll have time today but I will look tomorrow/Thursday. Are you cool if I push commits to this PR with tests? |
@joshdholtz Yes, please! Thank you very much :) I have also signed the CLA (using my both accounts). It seems an admin need to manually set it to |
@joshdholtz Any update, please? :) |
@joshdholtz Any help, please? :) Thanks in advance! |
@joshdholtz @taquitos @KrauseFx Kindly let me know how to add tests to Fastlane, please. I tried to add them but wasn't able to figure it out. If you can give me some tips on how to add them, I will try again. I am trying to move my script to a remote machine but would like to avoid configuring the remote machine to use my custom changes, would prefer to have the machine automatically update to latest version of Fastlane available! :) |
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.
Lint it up, then everything looks great!
🎈:goat:
2b014cb
to
8582bc9
Compare
@scorpion35 Merged! Thanks for making this changing 😊 |
You are the best, thank you very much @joshdholtz :) It seems I over thought about these tests, almost had it (ee69cfe), but over complicated it with some other changes :D haha. Thanks again! 🙇 Do you know when can I expect these changes in official Fastlane gem? |
Congratulations! 🎉 This was released as part of fastlane 2.103.0 🚀 |
* Limit reviews upto date specified. * Optimizations. Implemented suggestions from comments. * Removed debug line * Optimizations and simplified the code so it's easy to read. * Fixed linting Branch: "reviews_uptodate" | Commit Type: "Bug fix" | Changes tested: "no" * Test for reviews upto_date Branch: "reviews_uptodate" | Commit Type: "New test" | Changes tested: "no" * Bug fix in upto date test Branch: "reviews_uptodate" | Commit Type: "Minor" | Changes tested: "yes" * Revert "Bug fix in upto date test" This reverts commit ee69cfe. * Revert "Test for reviews upto_date" This reverts commit c57e713. * Added tests for new upto_date parameter
Issue: #13030
Solution: Added an optional
upto_date
parameter toget_review
methods. By limitingget_reviews
upto a certain date, the time to return from the method is reduced from hours to seconds!Examples -
Before: Time taken to get all reviews: ~ upto 2 hours (best case). Up to 5 hours (worst case), and the script crashes in the end.
After: Time taken to get reviews up to a specified date: ~ 2 secs (best case) to ~ 30 secs.