Bug 1243512 - Display version information for all experiments. r=bsmedberg
authorFelipe Gomes <felipc@gmail.com>
Wed, 10 Feb 2016 19:42:30 -0200
changeset 74 cefdc8498df33807be44e22aa0d45379e994bf7c
parent 73 ca06c3e9872f4e814c1d7ceb6a2bcb9d825409bc
child 75 455cd6114b968cfbcfc1b15fa79a86097c602168
push id57
push userfelipc@gmail.com
push dateThu, 11 Feb 2016 23:14:52 +0000
reviewersbsmedberg
bugs1243512
Bug 1243512 - Display version information for all experiments. r=bsmedberg
experiment.py
templates/index.xhtml
--- a/experiment.py
+++ b/experiment.py
@@ -51,16 +51,20 @@ def validate_buildids(d):
 def validate_sample(d):
     if d < 0 or d > 1:
         raise ValueError("Sample must be between 0 and 1, got %s" % (d,))
 
 def validate_bool(d):
     if not isinstance(d, bool):
         raise ValueError("Expected boolean type, got %s" % (d,))
 
+def ensure_no_conflicting_versions(keys):
+    if "version" in keys and ("minVersion" in keys or "maxVersion" in keys):
+        raise ValueError("version and min/maxVersion used at the same time")
+
 required = [
     ("id", validate_string),
     ("startTime", validate_time),
     ("endTime", validate_time),
     ("maxActiveSeconds", validate_max_seconds),
     ("appName", validate_app_name),
     ("channel", validate_string_list),
 ]
@@ -97,16 +101,19 @@ class Experiment(object):
         keys = set(d.keys())
         for k in meta:
             keys.remove(k)
             setattr(self, k, d[k])
         if len(keys):
             raise ValueError("Unexpected toplevel keys: %s" % (".".join(keys),))
 
         keys = set(self.manifest.keys())
+
+        ensure_no_conflicting_versions(keys)
+
         for k, validate in required:
             keys.remove(k)
             validate(self.manifest[k])
 
         for k, validate in optional:
             if k in keys:
                 validate(self.manifest[k])
                 keys.remove(k)
--- a/templates/index.xhtml
+++ b/templates/index.xhtml
@@ -62,25 +62,38 @@ def experiment_attrs(e):
         <dd>${to_date(e.manifest['maxStartTime'])}</dd>
       </py:if>
       <dt>End Date</dt><dd>${to_date(e.manifest['endTime'])}</dd>
       <dt>Maximum runtime</dt>
       <dd>${"%.1f" % (float(e.manifest["maxActiveSeconds"]) / 60 / 60 / 24)} days</dd>
       <dt py:if="e.manifest.get('disabled', False)">Disabled</dt>
       <dt py:if="e.manifest.get('frozen', False)">Frozen</dt>
       <dt>Update Channels</dt><dd>${",".join(e.manifest["channel"])}</dd>
-      <py:if test="'version' in e.manifest">
-        <dt>Firefox version(s)</dt>
-        <dd>${",".join(e.manifest["version"])}</dd>
-      </py:if>
+      <dt>Firefox version(s)</dt>
+      <dd>
+        <py:choose>
+          <py:when test="'version' in e.manifest">
+            ${", ".join(e.manifest["version"])}
+          </py:when>
+          <py:when test="'minVersion' in e.manifest or 'maxVersion' in e.manifest">
+            ${e.manifest.get("minVersion", "*")}
+            <py:if test="e.manifest.get('minVersion', '') != e.manifest.get('maxVersion', '')">
+              - ${e.manifest.get("maxVersion", "*")}
+            </py:if>
+          </py:when>
+          <py:otherwise>
+            All
+          </py:otherwise>
+        </py:choose>
+      </dd>
       <py:if test="'minBuildID' in e.manifest or 'maxBuildID' in e.manifest or 'buildIDs' in e.manifest">
         <dt>Build ID</dt>
         <dd>
           <py:if test="'minBuildID' in e.manifest or 'maxaBuildID' in e.manifest">
-            ${e.manifest.get("minBuildID", "")}-${e.manifest.get("maxBuildID", "")}
+            ${e.manifest.get("minBuildID", "")} - ${e.manifest.get("maxBuildID", "")}
           </py:if>
           ${",".join(e.manifest.get("buildIDs", []))}
         </dd>
       </py:if>
       <py:if test="'os' in e.manifest">
         <dt>Operating Systems</dt>
         <dd>${",".join(e.manifest["os"])}</dd>
       </py:if>