[llvm-commits] [LNT] r160745 - in /lnt/trunk/lnt/server/ui: templates/v4_daily_report.html views.py

Daniel Dunbar daniel at zuster.org
Wed Jul 25 11:23:07 PDT 2012


Author: ddunbar
Date: Wed Jul 25 13:23:07 2012
New Revision: 160745

URL: http://llvm.org/viewvc/llvm-project?rev=160745&view=rev
Log:
[lnt/v0.4] lnt.server.ui: Start work on a "daily report".
 - The idea is to try and provide a single report that adequately (and
   losslessly) summarizes the runs from any machine which has reported in the
   last N days.
 - Currently just comes up with the machines, runs, and orders to summarize.

Added:
    lnt/trunk/lnt/server/ui/templates/v4_daily_report.html
Modified:
    lnt/trunk/lnt/server/ui/views.py

Added: lnt/trunk/lnt/server/ui/templates/v4_daily_report.html
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/templates/v4_daily_report.html?rev=160745&view=auto
==============================================================================
--- lnt/trunk/lnt/server/ui/templates/v4_daily_report.html (added)
+++ lnt/trunk/lnt/server/ui/templates/v4_daily_report.html Wed Jul 25 13:23:07 2012
@@ -0,0 +1,53 @@
+{% set db = request.get_db() %}
+
+{% extends "layout.html" %}
+{% set components = [(ts.name, v4_url_for("v4_overview"))] %}
+{% block title %}Daily Report{% endblock %}
+{% block body %}
+
+<center><h2>{#
+  #}(<a href="{{v4_url_for('v4_daily_report',
+                          year=prior_days[1].year,
+                          month=prior_days[1].month,
+                          day=prior_days[1].day)}}">prev</a>){#
+  #}<b> Daily Overview {{ '%04d-%02d-%02d' % (
+      prior_days[0].year, prior_days[0].month, prior_days[0].day) }} </b>{#
+  #}(<a href="{{v4_url_for('v4_daily_report',
+                          year=next_day.year,
+                          month=next_day.month,
+                          day=next_day.day)}}">next</a>){#
+#}</h2>
+(day start is considered to be at +{{ "%02d:%02d" % (
+    (day_start_offset.seconds // 3600),
+    (day_start_offset.seconds // 60) % 60,)}})
+</center>
+
+{# Generate the table showing which run orders we are reporting on, for each
+   machine. #}
+<h3>Reported Machine Order<h3>
+<table border="1">
+  <thead>
+    <tr>
+      <th>Machine Name</th>
+{% for i in range(num_prior_days_to_include)|reverse %}
+      <th>Day - {{i}}</th>
+{% endfor %}
+    </tr>
+  </thead>
+{% for machine in reporting_machines %}
+  <tr>
+    <td>{{machine.name}}</td>
+{% for i in range(num_prior_days_to_include)|reverse %}
+{%   set order = prior_days_machine_order_map[i].get(machine) %}
+{%   if order %}
+    {# FIXME: Don't hard code field name. #}
+    <td>{{order.llvm_project_revision}}</td>
+{%   else %}
+    <td bgcolor="#FF0000">N/A</td>
+{%   endif %}
+{% endfor %}
+  </tr>
+{% endfor %}
+</table>
+
+{% endblock %}

Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=160745&r1=160744&r2=160745&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Wed Jul 25 13:23:07 2012
@@ -1078,6 +1078,78 @@
                            graph_plots=graph_plots, legend=legend,
                            use_day_axis=use_day_axis)
 
+ at v4_route("/daily_report/<int:year>/<int:month>/<int:day>")
+def v4_daily_report(year, month, day):
+    import datetime
+    from lnt.server.ui import util
+
+    ts = request.get_testsuite()
+
+    # The number of previous days we are going to report on.
+    num_prior_days_to_include = 3
+
+    # Construct datetime instances for the report range.
+    day_ordinal = datetime.datetime(year, month, day).toordinal()
+
+    next_day = datetime.datetime.fromordinal(day_ordinal + 1)
+    prior_days = [datetime.datetime.fromordinal(day_ordinal - i)
+                  for i in range(num_prior_days_to_include + 1)]
+
+    # Adjust the dates time component.  As we typically want to do runs
+    # overnight, we define "daily" to really mean "at 0700".
+    day_start_offset = datetime.timedelta(hours=7)
+    next_day += day_start_offset
+    for i,day in enumerate(prior_days):
+        prior_days[i] = day + day_start_offset
+
+    # Find all the runs that occurred for each day slice.
+    prior_runs = [ts.query(ts.Run).\
+                      filter(ts.Run.start_time > prev_day).\
+                      filter(ts.Run.start_time <= day).all()
+                  for day,prev_day in util.pairs(prior_days)]
+
+    # For every machine, we only want to report on the last run order that was
+    # reported for that machine for the particular day range.
+    #
+    # Note that this *does not* mean that we will only report for one particular
+    # run order for each day, because different machines may report on different
+    # orders.
+    #
+    # However, we want to limit ourselves to a single run order for each
+    # (day,machine) so that we don't obscure any details through our
+    # aggregation.
+    prior_days_machine_order_map = [None] * num_prior_days_to_include
+    for i,runs in enumerate(prior_runs):
+        # Aggregate the runs by machine.
+        machine_to_all_orders = util.multidict()
+        for r in runs:
+            machine_to_all_orders[r.machine] = r.order
+
+        # Create a map from machine to max order.
+        prior_days_machine_order_map[i] = machine_order_map = dict(
+            (machine, max(orders))
+            for machine,orders in machine_to_all_orders.items())
+
+        # Update the run list to only include the runs with that order.
+        prior_runs[i] = [r for r in runs
+                         if r.order is machine_order_map[r.machine]]
+
+    # Form a list of all relevant runs.
+    relevant_runs = [r
+                     for runs in prior_runs
+                     for r in runs]
+
+    # Find the union of all machines reporting in the relevant runs.
+    reporting_machines = list(set(r.machine for r in relevant_runs))
+    reporting_machines.sort(key = lambda m: m.name)
+
+    return render_template(
+        "v4_daily_report.html", ts=ts, day_start_offset=day_start_offset,
+        num_prior_days_to_include=num_prior_days_to_include,
+        reporting_machines=reporting_machines,
+        prior_days=prior_days, next_day=next_day,
+        prior_days_machine_order_map=prior_days_machine_order_map)
+
 ###
 # Cross Test-Suite V4 Views
 





More information about the llvm-commits mailing list