From aef37870d91a14dfc8f836edb700af1cd11a8de5 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Mon, 7 Dec 2015 01:45:34 -0800 Subject: [PATCH] Numerous small fixes from release testing: remove spaces from thumbnail icon URLs, guard against non-existent models in jobs if explorations are deleted, round ratings to 1 decimal place, add "(Oppia moderator)" to the Oppia moderator email signoff text, add an index for the realtime job for the user impact calculation. --- core/domain/exp_jobs_one_off.py | 6 ++++-- core/domain/exp_services.py | 2 +- core/domain/user_jobs_continuous.py | 5 ++++- core/domain/user_jobs_one_off.py | 5 ++--- core/storage/base_model/gae_models.py | 7 ++++++- .../dev/head/components/explorationSummaryTile.js | 4 ++-- .../dev/head/components/exploration_summary_tile.html | 2 +- core/templates/dev/head/editor/exploration_settings.html | 2 +- feconf.py | 2 +- index.yaml | 5 +++++ .../gallery/thumbnails/{Life Skills.svg => LifeSkills.svg} | 0 utils.py | 3 ++- utils_test.py | 3 +++ 13 files changed, 32 insertions(+), 14 deletions(-) rename static/images/gallery/thumbnails/{Life Skills.svg => LifeSkills.svg} (100%) diff --git a/core/domain/exp_jobs_one_off.py b/core/domain/exp_jobs_one_off.py index c42593b049f7..3043c26f4853 100644 --- a/core/domain/exp_jobs_one_off.py +++ b/core/domain/exp_jobs_one_off.py @@ -81,9 +81,11 @@ def map(item): @staticmethod def reduce(exp_id, committer_id_list): - committer_ids = set(committer_id_list) exp_summary_model = exp_models.ExpSummaryModel.get_by_id(exp_id) - exp_summary_model.contributor_ids = list(committer_ids) + if exp_summary_model is None: + return + + exp_summary_model.contributor_ids = list(set(committer_id_list)) exp_summary_model.put() diff --git a/core/domain/exp_services.py b/core/domain/exp_services.py index cfe01bbb7110..a99cf48e2bb9 100644 --- a/core/domain/exp_services.py +++ b/core/domain/exp_services.py @@ -238,7 +238,7 @@ def get_multiple_explorations_by_id(exp_ids, strict=True): def get_displayable_exp_summary_dicts_matching_ids( - exploration_ids, user_id): + exploration_ids, user_id): """Given a list of exploration ids, filters the list for explorations that are currently non-private and not deleted, and returns a list of dicts of the corresponding exploration summaries. diff --git a/core/domain/user_jobs_continuous.py b/core/domain/user_jobs_continuous.py index 29c3f3068084..f3be3c7635bc 100644 --- a/core/domain/user_jobs_continuous.py +++ b/core/domain/user_jobs_continuous.py @@ -361,6 +361,9 @@ def _get_exp_impact_score(cls, exploration_id): @staticmethod def map(item): + if item.deleted: + return + exploration_impact_score = ( UserImpactMRJobManager._get_exp_impact_score(item.id)) @@ -377,4 +380,4 @@ def map(item): def reduce(key, stringified_values): values = [ast.literal_eval(v) for v in stringified_values] user_impact_score = int(round(sum(values))) - user_models.UserStatsModel(id=key, impact_score=user_impact_score).put() \ No newline at end of file + user_models.UserStatsModel(id=key, impact_score=user_impact_score).put() diff --git a/core/domain/user_jobs_one_off.py b/core/domain/user_jobs_one_off.py index 66d4dda20198..5de7256770bb 100644 --- a/core/domain/user_jobs_one_off.py +++ b/core/domain/user_jobs_one_off.py @@ -39,10 +39,9 @@ def entity_classes_to_map_over(cls): @staticmethod def map(item): if isinstance(item, exp_models.ExplorationSnapshotMetadataModel): - split_id = item.id.rsplit('-') yield (item.committer_id, { - 'version_string': split_id[1], - 'exploration_id': split_id[0] + 'exploration_id': item.get_unversioned_instance_id(), + 'version_string': item.get_version_string(), }) @staticmethod diff --git a/core/storage/base_model/gae_models.py b/core/storage/base_model/gae_models.py index b9036b6a6f20..901e59341880 100644 --- a/core/storage/base_model/gae_models.py +++ b/core/storage/base_model/gae_models.py @@ -18,7 +18,6 @@ from core.platform import models transaction_services = models.Registry.import_transaction_services() -import feconf import utils from google.appengine.datastore import datastore_query @@ -461,6 +460,9 @@ class BaseSnapshotMetadataModel(BaseModel): def get_unversioned_instance_id(self): return self.id[:self.id.rfind(_VERSION_DELIMITER)] + def get_version_string(self): + return self.id[self.id.rfind(_VERSION_DELIMITER) + 1:] + class BaseSnapshotContentModel(BaseModel): """Base class for snapshot content classes. @@ -476,6 +478,9 @@ class BaseSnapshotContentModel(BaseModel): def get_unversioned_instance_id(self): return self.id[:self.id.rfind(_VERSION_DELIMITER)] + def get_version_string(self): + return self.id[self.id.rfind(_VERSION_DELIMITER) + 1:] + class BaseMapReduceBatchResultsModel(BaseModel): """Base model for batch storage for MR jobs. diff --git a/core/templates/dev/head/components/explorationSummaryTile.js b/core/templates/dev/head/components/explorationSummaryTile.js index 7bbad0184204..256763699637 100644 --- a/core/templates/dev/head/components/explorationSummaryTile.js +++ b/core/templates/dev/head/components/explorationSummaryTile.js @@ -44,8 +44,8 @@ oppia.directive('explorationSummaryTile', [function() { oppiaDatetimeFormatter.getLocaleAbbreviatedDatetimeString( $scope.getLastUpdatedMsec())); - $scope.averageRating = ratingComputationService.computeAverageRating( - $scope.getRatings()); + $scope.averageRating = ( + ratingComputationService.computeAverageRating($scope.getRatings())); $scope.explorationLink = '/explore/' + $scope.getExplorationId(); if ($scope.getCollectionId()) { diff --git a/core/templates/dev/head/components/exploration_summary_tile.html b/core/templates/dev/head/components/exploration_summary_tile.html index 61c32f7e278c..960ee0b17d8f 100644 --- a/core/templates/dev/head/components/exploration_summary_tile.html +++ b/core/templates/dev/head/components/exploration_summary_tile.html @@ -122,7 +122,7 @@

<[getExplor - <[averageRating]> + <[averageRating | number:1]> diff --git a/core/templates/dev/head/editor/exploration_settings.html b/core/templates/dev/head/editor/exploration_settings.html index 9241ce134a0e..0c6bc1f83986 100644 --- a/core/templates/dev/head/editor/exploration_settings.html +++ b/core/templates/dev/head/editor/exploration_settings.html @@ -496,7 +496,7 @@

Feature exploration (as moderator

Doing so will send the following email to all exploration owners; please edit it as needed. (NB: do not include a salutation or a - signoff -- the text "Hi [username]" and "Thanks, [your username]" will + signoff -- the text "Hi [username]" and "Thanks! [your username] (Oppia moderator)" will be auto-added.)

diff --git a/feconf.py b/feconf.py index e312a3bb5287..2e64367b1593 100644 --- a/feconf.py +++ b/feconf.py @@ -171,7 +171,7 @@ def get_empty_ratings(): DEFAULT_SALUTATION_HTML_FN = ( lambda recipient_username: 'Hi %s,' % recipient_username) DEFAULT_SIGNOFF_HTML_FN = ( - lambda sender_username: 'Thanks,
%s' % sender_username) + lambda sender_username: 'Thanks!
%s (Oppia moderator)' % sender_username) VALID_MODERATOR_ACTIONS = { MODERATOR_ACTION_PUBLICIZE_EXPLORATION: { diff --git a/index.yaml b/index.yaml index 7ab0ff795989..348406a5e923 100644 --- a/index.yaml +++ b/index.yaml @@ -96,6 +96,11 @@ indexes: - name: realtime_layer - name: created_on +- kind: UserImpactRealtimeModel + properties: + - name: realtime_layer + - name: created_on + - kind: _AE_Pipeline_Record properties: - name: is_root_pipeline diff --git a/static/images/gallery/thumbnails/Life Skills.svg b/static/images/gallery/thumbnails/LifeSkills.svg similarity index 100% rename from static/images/gallery/thumbnails/Life Skills.svg rename to static/images/gallery/thumbnails/LifeSkills.svg diff --git a/utils.py b/utils.py index 8c4e1dc41072..338bda4105d3 100644 --- a/utils.py +++ b/utils.py @@ -433,4 +433,5 @@ def get_thumbnail_icon_url_for_category(category): icon_name = ( category if category in feconf.DEFAULT_CATEGORIES else feconf.DEFAULT_THUMBNAIL_ICON) - return '/images/gallery/thumbnails/%s.svg' % icon_name + # Remove all spaces from the string. + return '/images/gallery/thumbnails/%s.svg' % icon_name.replace(' ', '') diff --git a/utils_test.py b/utils_test.py index 3b944a69bc0f..1f41629320f9 100644 --- a/utils_test.py +++ b/utils_test.py @@ -192,6 +192,9 @@ def test_get_thumbnail_icon_url_for_category(self): self.assertEqual( utils.get_thumbnail_icon_url_for_category('Architecture'), '/images/gallery/thumbnails/Architecture.svg') + self.assertEqual( + utils.get_thumbnail_icon_url_for_category('Life Skills'), + '/images/gallery/thumbnails/LifeSkills.svg') self.assertEqual( utils.get_thumbnail_icon_url_for_category('Nonexistent'), '/images/gallery/thumbnails/Lightbulb.svg')