#250 [frontend] several tweaks for graphs of utilization
Merged 6 years ago by clime. Opened 6 years ago by dturecek.
copr/ dturecek/copr graphs  into  master

@@ -84,7 +84,7 @@ 

          return list(query.all()[:4])

  

      @classmethod

-     def get_tasks_by_time(cls, start, end):

+     def get_running_tasks_by_time(cls, start, end):

          result = models.BuildChroot.query\

              .filter(models.BuildChroot.ended_on > start)\

              .filter(models.BuildChroot.started_on < end)\
@@ -93,11 +93,11 @@ 

          return result

  

      @classmethod

-     def get_tasks_from_last_day(cls):

+     def get_running_tasks_from_last_day(cls):

          end = int(time.time())

          start = end - 86399

          step = 3600

-         tasks = cls.get_tasks_by_time(start, end)

+         tasks = cls.get_running_tasks_by_time(start, end)

          steps = int(round((end - start) / step + 0.5))

          current_step = 0

  

@@ -5,8 +5,8 @@ 

  });

  

  function graphConfig() {

-     var colorPattern = ['#0088ce', '#cc0000', '#3f9c35', '#003d44', '#ec7a08', '#703fec',

-     '#470000', '#35caed', '#92d400', '#f5c12e'];

+     var colorPattern = ['#0088ce', '#cc0000', '#3f9c35', '#f5c12e', '#703fec',

+                         '#003d44', '#35caed', '#ec7a08', '#470000', '#92d400'];

      var chart = {

          axis: {

              x: {
@@ -55,6 +55,7 @@ 

          format: format

      };

      chart.bindto = bind;

+     chart.color.pattern = ['#cc8844', '#0088ce'];

      chart.data.columns = data;

      var chartDay = c3.generate(chart);

  };
@@ -85,6 +86,7 @@ 

      var c3ChartDefaults = $().c3ChartDefaults();

      var sparklineChartConfig = c3ChartDefaults.getDefaultSparklineConfig();

      sparklineChartConfig.bindto = bind;

+     sparklineChartConfig.color = {pattern: ['#cc8844']}

      sparklineChartConfig.data = {

          columns: data,

          type: 'area'

@@ -291,7 +291,7 @@ 

          Running

        </a>

        <a id="stats-link" href="{{url_for('status_ns.stats')}}" class="list-group-item hidden">

-         Tasks during last 24 hours:

+         Running tasks during last 24 hours:

          <div id="small-graph" class="chart-pf-sparkline"></div>

        </a>

      </div>

@@ -16,15 +16,15 @@ 

  </noscript>

  <div id="graphs" class="hidden">

    <div class="row">

-     <h3>Tasks during last 24 hours</h3>

+     <h3>Running tasks during last 24 hours</h3>

      <div id="chartDay" class="line-chart-pf"></div>

    </div>

    <div class="row">

-     <h3>Tasks during last 90 days</h3>

+     <h3>Running tasks during last 90 days</h3>

        <div id="chartNinetyDays" class="line-chart-pf"></div>

    </div>

    <div class="row">

-     <h3>Tasks divided by chroots</h3>

+     <h3>Running tasks divided by chroots</h3>

      <div class="col-md-1"></div>

      <div class="col-md-5">

        <h4>During last 24 hours</h4>
@@ -43,8 +43,8 @@ 

  <script src="{{ url_for('static', filename='components/d3/d3.min.js') }}"></script>

  <script src="{{ url_for('static', filename='js/graphs.js') }}"></script>

  <script>

-   lineGraph({{ data1|tojson }}, 48, "#chartDay", "%H:%M");

-   lineGraph({{ data2|tojson }}, 20, "#chartNinetyDays", "%Y-%m-%d");

+   lineGraph({{ data1|tojson }}, 25, "#chartDay", "%H:%M");

+   lineGraph({{ data2|tojson }}, 15, "#chartNinetyDays", "%Y-%m-%d");

    chrootGraph({{ chroots1|tojson }}, "#chartChrootsDay");

    chrootGraph({{ chroots2|tojson }}, "#chartChrootsNinetyDays");

  </script>

@@ -77,7 +77,7 @@ 

      # users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 5)

      users_builds = builds_logic.BuildsLogic.get_recent_tasks(None, 4)

  

-     data = builds_logic.BuildsLogic.get_tasks_from_last_day()

+     data = builds_logic.BuildsLogic.get_running_tasks_from_last_day()

  

      return flask.render_template("coprs/show/all.html",

                                   coprs=coprs,
@@ -106,7 +106,7 @@ 

      # flask.g.user is none when no user is logged - showing builds from everyone

      users_builds = builds_logic.BuildsLogic.get_recent_tasks(flask.g.user, 4)

  

-     data = builds_logic.BuildsLogic.get_tasks_from_last_day()

+     data = builds_logic.BuildsLogic.get_running_tasks_from_last_day()

  

      return flask.render_template("coprs/show/user.html",

                                   user=user,
@@ -131,7 +131,7 @@ 

      paginator = helpers.Paginator(query, query.count(), page,

                                    additional_params={"fulltext": fulltext})

  

-     data = builds_logic.BuildsLogic.get_tasks_from_last_day()

+     data = builds_logic.BuildsLogic.get_running_tasks_from_last_day()

  

      coprs = paginator.sliced_query

      return render_template("coprs/show/fulltext.html",

@@ -66,7 +66,7 @@ 

  

      coprs = paginator.sliced_query

  

-     data = builds_logic.BuildsLogic.get_tasks_from_last_day()

+     data = builds_logic.BuildsLogic.get_running_tasks_from_last_day()

  

      return render_template(

          "coprs/show/group.html",

@@ -10,7 +10,7 @@ 

      chroots_dict = {}

      chroots = []

      chroot_names = {}

-     tasks = builds_logic.BuildsLogic.get_tasks_by_time(start, end)

+     tasks = builds_logic.BuildsLogic.get_running_tasks_by_time(start, end)

      steps = int(round((end - start) / step + 0.5))

      current_step = 0

  
@@ -75,9 +75,9 @@ 

  

  @status_ns.route("/stats/")

  def stats():

-     current_time = int(time.time())

-     data1, chroots1 = get_graph_data(current_time - 86400 + 1, current_time, 600) # last 24 hours

-     data2, chroots2 = get_graph_data(current_time - 86400 * 90 + 1, current_time, 86400) # last 90 days

+     current_time = int(time.time()) - int(time.time()) % 600

+     data1, chroots1 = get_graph_data(current_time - 86400, current_time - 1, 600) # last 24 hours

+     data2, chroots2 = get_graph_data(current_time - 86400 * 90, current_time - 1, 86400) # last 90 days

      return flask.render_template("status/stats.html",

                                   data1=data1,

                                   data2=data2,

This PR addresses Issue #244.
Changes made:
- graph titles mention that they show running tasks
- methods used for getting graph data renamed to get_running_tasks*
- change colors for the graph (I chose option 1 from Issue #244 - same color as running tasks)
- reduce the number of x.axis labels so that they don't overlap on lower resolution/smaller displays
- rearrange the order of colors in chroots graph so that there aren't similar colors next to each other

Pull-Request has been merged by clime

6 years ago