Skip to content

Commit

Permalink
Numerous small fixes from release testing: remove spaces from thumbna…
Browse files Browse the repository at this point in the history
…il 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.
  • Loading branch information
seanlip committed Dec 7, 2015
1 parent bfe4576 commit aef3787
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 14 deletions.
6 changes: 4 additions & 2 deletions core/domain/exp_jobs_one_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion core/domain/exp_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion core/domain/user_jobs_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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()
user_models.UserStatsModel(id=key, impact_score=user_impact_score).put()
5 changes: 2 additions & 3 deletions core/domain/user_jobs_one_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion core/storage/base_model/gae_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions core/templates/dev/head/components/explorationSummaryTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h2 class="exploration-title protractor-test-exp-summary-tile-title"><[getExplor
<span ng-if="averageRating">
<span class="fa fa-star fa-lg" tooltip="Ratings" tooltip-placement="top">
</span>
<[averageRating]>
<[averageRating | number:1]>
</span>
</li>

Expand Down
2 changes: 1 addition & 1 deletion core/templates/dev/head/editor/exploration_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ <h3 ng-if="action === 'publicize_exploration'">Feature exploration (as moderator
<p>
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.)
</p>

Expand Down
2 changes: 1 addition & 1 deletion feconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,<br>%s' % sender_username)
lambda sender_username: 'Thanks!<br>%s (Oppia moderator)' % sender_username)

VALID_MODERATOR_ACTIONS = {
MODERATOR_ACTION_PUBLICIZE_EXPLORATION: {
Expand Down
5 changes: 5 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ', '')
3 changes: 3 additions & 0 deletions utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit aef3787

Please sign in to comment.