From 08077fdbc299fad6fa4ea2db5d58bb6b4989c6f1 Mon Sep 17 00:00:00 2001
From: Branson Stephens <branson.stephens@ligo.org>
Date: Fri, 26 Sep 2014 15:26:21 -0500
Subject: [PATCH] Fixed make_histogram command so that you get one histogram
 per pipeline, instead of one histogram per analysisType. This will mix
 HighMass and LowMass events, so we may want to split on search, where search
 is available. But I don't think it's that criticial since we aren't using
 these histograms much.

---
 gracedb/management/commands/make_histograms.py | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gracedb/management/commands/make_histograms.py b/gracedb/management/commands/make_histograms.py
index 4bd218553..37bfeabfe 100644
--- a/gracedb/management/commands/make_histograms.py
+++ b/gracedb/management/commands/make_histograms.py
@@ -10,7 +10,7 @@ matplotlib.use("Agg")
 import matplotlib.pyplot as pyplot
 import numpy
 
-from gracedb.models import Event
+from gracedb.models import Event, Pipeline
 
 import os
 from datetime import datetime, timedelta
@@ -40,13 +40,15 @@ class Command(NoArgsCommand):
         annotations = {}
 
         # Make the histograms, save as png's.
-        for atype, atype_name in Event.ANALYSIS_TYPE_CHOICES:
-            annotations[atype] = {}
+        for pipeline in Pipeline.objects.all():
+#        for atype, atype_name in Event.ANALYSIS_TYPE_CHOICES:
+            pname = pipeline.name
+            annotations[pname] = {}
             for start_time, time_range in time_ranges:
                 note = {}
-                fname = os.path.join(DEST_DIR, "%s-%s.png" % (atype, time_range))
+                fname = os.path.join(DEST_DIR, "%s-%s.png" % (pname, time_range))
                 note['fname'] = fname
-                data = Event.objects.filter(analysisType=atype,
+                data = Event.objects.filter(pipeline=pipeline,
                                             created__range=[start_time, now],
                                             gpstime__gt=0) \
                                     .exclude(group__name="Test")
@@ -62,8 +64,8 @@ class Command(NoArgsCommand):
                     except OSError:
                         pass
                 else:
-                    makePlot(data, atype, maxx=MAX_X).savefig(fname)
-                annotations[atype][time_range] = note
+                    makePlot(data, pname, maxx=MAX_X).savefig(fname)
+                annotations[pname][time_range] = note
 
         writeIndex(annotations, WEB_PAGE_FILE_PATH)
 
-- 
GitLab