-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix part of #5002 remove GCS_RESOURCE_BUCKET_NAME from GLOBALS #7130
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #7130 +/- ##
===========================================
+ Coverage 98.06% 98.06% +<.01%
===========================================
Files 377 379 +2
Lines 63086 63116 +30
===========================================
+ Hits 61864 61894 +30
Misses 1222 1222
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #7130 +/- ##
===========================================
- Coverage 98.62% 89.34% -9.29%
===========================================
Files 381 1198 +817
Lines 64057 96865 +32808
Branches 0 2469 +2469
===========================================
+ Hits 63179 86544 +23365
- Misses 878 9806 +8928
- Partials 0 515 +515
Continue to review full report at Codecov.
|
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! Few comments.
window.MSBlobBuilder; | ||
window.WebKitBlobBuilder || | ||
window.MozBlobBuilder || | ||
window.MSBlobBuilder; |
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 change?
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.
Unnecessary. I think it is due to my editor formatting.
Removed.
GCS_PREFIX = ('https://storage.googleapis.com/' + | ||
GCS_RESOURCE_BUCKET_NAME + '/exploration'); | ||
AUDIO_DOWNLOAD_URL_TEMPLATE = ( | ||
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) + |
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 do you need to check DEV_MODE
here? Shouldn't this be handled on line 51?
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, removed.
var _initialize = function() { | ||
if (DEV_MODE) { | ||
// GCS_PREFIX = ('https://storage.googleapis.com/' + | ||
// GCS_RESOURCE_BUCKET_NAME + '/exploration'); |
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 is this commented out?
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 prefix is only used in PROD
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! Few comments.
@@ -63,19 +61,17 @@ oppia.factory('AssetsBackendApiService', [ | |||
} | |||
|
|||
$http.get('/appidentityhandler').then(function(response) { | |||
if (!DEV_MODE && !response.data.GCS_RESOURCE_BUCKET_NAME) { | |||
if (!response.data.GCS_RESOURCE_BUCKET_NAME) { | |||
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.'); | |||
} |
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.
Now that I think of it. Remove this if
altogether.
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 don't think this if should be removed since it validated the result gotten from the handler
@@ -63,19 +61,17 @@ oppia.factory('AssetsBackendApiService', [ | |||
} | |||
|
|||
$http.get('/appidentityhandler').then(function(response) { | |||
if (!DEV_MODE && !response.data.GCS_RESOURCE_BUCKET_NAME) { | |||
if (!response.data.GCS_RESOURCE_BUCKET_NAME) { | |||
throw Error('GCS_RESOURCE_BUCKET_NAME is not set in prod.'); | |||
} | |||
GCS_RESOURCE_BUCKET_NAME = response.data.GCS_RESOURCE_BUCKET_NAME; | |||
}).then(function() { |
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.
Do we need to chain the .then(
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.
No
Removed. Thanks.
Hi @Jamesjay4199. Due to recent changes in the "develop" branch, this PR now has a merge conflict. Please follow this link if you need help resolving the conflict, so that the PR can be merged. Thanks! |
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.
Took another pass, thanks @Jamesjay4199.
Could you please describe your manual testing procedure for this PR? I suggest doing that in general for PRs that you do from now onwards, in order to avoid cases like the recent regressions.
var IMAGE_DOWNLOAD_URL_TEMPLATE = ( | ||
(DEV_MODE ? '/assetsdevhandler' : GCS_PREFIX) + | ||
'/<exploration_id>/assets/image/<filename>'); | ||
if (_initialized) { |
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.
Perhaps this should come at the very beginning of the function?
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.
|
||
var AUDIO_UPLOAD_URL_TEMPLATE = | ||
'/createhandler/audioupload/<exploration_id>'; | ||
$http.get('/gcs_resource_bucket_name_handler').then(function(response) { |
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.
Don't you need to return this?
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.
True. Done.
exploration_id: explorationId, | ||
filename: filename | ||
}); | ||
if (_initialized) { |
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.
Do you need this clause? I thought the "if _initialized" check in _initialize() should take care of it seamlessly. It would be better to drop lines 230-238 as long as you verify the code is still correct.
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. Thanks.
@@ -96,8 +96,12 @@ oppia.directive('oppiaInteractiveImageClickInput', [ | |||
// preview mode. We don't have loading indicator or try again for | |||
// showing images in the exploration editor or in preview mode. So | |||
// we directly assign the url to the imageUrl. | |||
ctrl.imageUrl = AssetsBackendApiService.getImageUrlForPreview( | |||
ContextService.getExplorationId(), ctrl.filepath); | |||
AssetsBackendApiService.getImageUrlForPreview( |
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.
For async methods can you rename them to have async in the name? E.g. getImageUrlForPreviewAsync, get TrustedResourceUrlForImageFileNameAsync, etc.
Ditto elsewhere.
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.
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.
LGTM!
Backend tests are failing, @Jamesjay4199 . |
Also, did you see this comment? Please address it.
|
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, looks good @Jamesjay4199. Just one small comment.
That said, the bigger comment is the one about manual testing. Please address that. I will wait on that before giving LGTM.
@@ -227,22 +227,13 @@ oppia.factory('AssetsBackendApiService', [ | |||
}; | |||
|
|||
var _getDownloadUrl = function(explorationId, filename, assetType) { |
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.
Change to _getDownloadUrlAsync
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
Sorry for the delays, I did the testing again to confirm. However, I think there should be more testing since the bucket name is going to be null while testing it locally. |
Thanks for confirming @Jamesjay4199. I'll add a note to the August release notes doc to make sure to verify this when we push to the test server, though typically you should be testing this on your own deployment. |
expect( | ||
AssetsBackendApiService.getAudioDownloadUrl('expid12345', 'a.mp3') | ||
).toEqual('/assetsdevhandler/expid12345/assets/audio/a.mp3'); | ||
AssetsBackendApiService.getAudioDownloadUrlAsync('expid12345', 'a.mp3') |
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.
@Jamesjay4199 I just realized something (after I merged) about this test. Change the URL on line 70 to something random and run the frontend tests. Do they pass?
If so, please rework this test to call done()
after the async call. See https://jasmine.github.io/2.0/introduction.html#section-Asynchronous_Support. Do this for other async calls.
Please address this in a separate follow-up PR.
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.
Addressed in https://github.com/oppia/oppia/pull/7244/files
Also, @Jamesjay4199, please do a test of this functionality on a prod server of your own. If you have trouble doing that please email me and Vojta and we can help you get it set up. If this causes problems during the release -- that would not be great. /cc @vojtechjelinek |
…LOBALS (oppia#7130)" This reverts commit a7bb506.
Explanation
Fixes part of #5002 remove GCS_RESOURCE_BUCKET_NAME from GLOBALS
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.