Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: telemetry/telemetry/story/story_set.py

Issue 2153513002: [Telemetry] Ensure that story display names are unique (Closed) Base URL: git@github.com:catapult-project/catapult.git@master
Patch Set: Use set-based check Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « telemetry/telemetry/story/story.py ('k') | telemetry/telemetry/story/story_set_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: telemetry/telemetry/story/story_set.py
diff --git a/telemetry/telemetry/story/story_set.py b/telemetry/telemetry/story/story_set.py
index 667cbd01ebb7b9b3114da16ae16933335b97f9ef..6fa319a9294a5057bbafd8f6604d57f173bf861b 100644
--- a/telemetry/telemetry/story/story_set.py
+++ b/telemetry/telemetry/story/story_set.py
@@ -32,6 +32,7 @@ class StorySet(object):
storage.
"""
self.stories = []
+ self.story_names_and_grouping_keys = set()
nednguyen 2016/12/02 19:59:58 Can you make this private? Things that are not sup
eakuefner 2016/12/02 20:28:58 Done. Also made stories private, since now it's cr
self._archive_data_file = archive_data_file
self._wpr_archive_info = None
archive_info.AssertValidCloudStorageBucket(cloud_storage_bucket)
@@ -98,7 +99,16 @@ class StorySet(object):
def AddStory(self, story):
assert isinstance(story, story_module.Story)
+ assert self._IsUnique(story), ('Tried to add story with duplicate display '
+ 'name %s. Story display names should be '
+ 'unique.' % story.display_name)
self.stories.append(story)
+ self.story_names_and_grouping_keys.add(
+ story.display_name_and_grouping_key_tuple)
+
+ def _IsUnique(self, story):
+ return (story.display_name_and_grouping_key_tuple not in
+ self.story_names_and_grouping_keys)
def RemoveStory(self, story):
"""Removes a Story.
« no previous file with comments | « telemetry/telemetry/story/story.py ('k') | telemetry/telemetry/story/story_set_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698