#1486 frontend: count srpm builds in statistics
Merged 3 years ago by praiskup. Opened 3 years ago by dturecek.
copr/ dturecek/copr srpm-stats  into  master

@@ -253,9 +253,12 @@ 

      @staticmethod

      def get_queue_sizes():

          importing = BuildsLogic.get_build_importing_queue(background=False).count()

-         pending = BuildsLogic.get_pending_build_tasks(background=False).count()

-         running = BuildsLogic.get_build_tasks(StatusEnum("running")).count()

-         starting = BuildsLogic.get_build_tasks(StatusEnum("starting")).count()

+         pending = BuildsLogic.get_pending_build_tasks(background=False).count() +\

+             BuildsLogic.get_pending_srpm_build_tasks(background=False).count()

+         running = BuildsLogic.get_build_tasks(StatusEnum("running")).count() +\

+             BuildsLogic.get_srpm_build_tasks(StatusEnum("running")).count()

+         starting = BuildsLogic.get_build_tasks(StatusEnum("starting")).count() +\

+             BuildsLogic.get_srpm_build_tasks(StatusEnum("starting")).count()

  

          return dict(

              importing=importing,

@@ -689,28 +689,38 @@ 

          </tr>

        </thead>

        <tbody>

-         {% for task in tasks %}

-           {% set build_chroot = task if type == 'importing' else task.build %}

+         {% for task_type, time, task in tasks %}

+           {% set build_chroot = task if type == 'importing' or task_type == 'srpm' else task.build %}

            <tr>

-             {% if type != 'running' %}

-               <td data-order="{{ build_chroot.submitted_on }}">{{ build_chroot.submitted_on | time_ago }}</td>

-             {% else %}

-               <td data-order="{{ build_chroot.started_on }}">{{ build_chroot.started_on | time_ago }}</td>

-             {% endif %}

-               <td data-order="{{ copr_name(build_chroot.copr) }}">

-                 <a href="{{ copr_details_href(build_chroot.copr) }}">

-                   {{ copr_name(build_chroot.copr) }}

-                 </a>

-               </td>

-               <td data-order="{{ build_chroot.id }}">

-                 <a href="{{ build_href(build_chroot) }}">

-                   {{ build_chroot.id }}

-                 </a>

-               </td>

+             <td data-order="{{ time }}">{{ time | time_ago }}</td>

+             <td data-order="{{ copr_name(build_chroot.copr) }}">

+               <a href="{{ copr_details_href(build_chroot.copr) }}">

+                 {{ copr_name(build_chroot.copr) }}

+               </a>

+             </td>

+             <td data-order="{{ build_chroot.id }}">

+               <a href="{{ build_href(build_chroot) }}">

+                 {{ build_chroot.id }}

+               </a>

+             </td>

              {% if type != 'importing' %}

-               <td data-order="{{ task.build.package.name }}">{{ task.build.package.name }} </td>

-               <td data-order="{{ task.build.pkg_version }}">{{ task.build.pkg_version }} </td>

-               <td data-order="{{ task.mock_chroot.name }}">{{ task.mock_chroot.name }}</td>

+               {% if task_type == 'srpm' %}

+                 {% if (task.package is not none) and (task.package.name is not none) %}

+                   <td data-order="{{ task.package.name }}">{{ task.package.name }} </td>

+                 {% else %}

+                   <td data-order="-">-</td>

+                 {% endif %}

+                 {% if task.pkg_version is not none %}

+                   <td data-order="{{ task.pkg_version }}">{{ task.pkg_version }} </td>

+                 {% else %}

+                   <td data-order="-">-</td>

+                 {% endif %}

+                 <td data-order="srpm build">srpm build</td>

+               {% else %}

+                 <td data-order="{{ task.build.package.name }}">{{ task.build.package.name }} </td>

+                 <td data-order="{{ task.build.pkg_version }}">{{ task.build.pkg_version }} </td>

+                 <td data-order="{{ task.mock_chroot.name }}">{{ task.mock_chroot.name }}</td>

+               {% endif %}

              {% endif %}

            </tr>

          {% endfor %}

@@ -15,14 +15,31 @@ 

  @status_ns.route("/")

  @status_ns.route("/pending/")

  def pending():

-     tasks = builds_logic.BuildsLogic.get_pending_build_tasks(background=False).all()

+     rpm_tasks = builds_logic.BuildsLogic.get_pending_build_tasks(background=False).all()

      bg_tasks_cnt = builds_logic.BuildsLogic.get_pending_build_tasks(background=True).count()

+     tasks = list(zip(["rpm"] * len(rpm_tasks),

+                      [x.build.submitted_on for x in rpm_tasks],

+                      rpm_tasks))

+     srpm_tasks = builds_logic.BuildsLogic.get_pending_srpm_build_tasks(background=False).all()

+     bg_tasks_cnt += builds_logic.BuildsLogic.get_pending_srpm_build_tasks(background=True).count()

+     srpm_tasks = list(zip(["srpm"] * len(srpm_tasks),

+                           [x.submitted_on for x in srpm_tasks],

+                           srpm_tasks))

+     tasks.extend(srpm_tasks)

      return render_status("pending", tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)

  

  

  @status_ns.route("/running/")

  def running():

-     tasks = builds_logic.BuildsLogic.get_build_tasks(StatusEnum("running")).all()

+     rpm_tasks = builds_logic.BuildsLogic.get_build_tasks(StatusEnum("running")).all()

+     tasks = list(zip(["rpm"] * len(rpm_tasks),

+                      [x.started_on for x in rpm_tasks],

+                      rpm_tasks))

+     srpm_tasks = builds_logic.BuildsLogic.get_srpm_build_tasks(StatusEnum("running")).all()

+     srpm_tasks = list(zip(["srpm"] * len(srpm_tasks),

+                           [x.submitted_on for x in srpm_tasks],

+                           srpm_tasks))

+     tasks.extend(srpm_tasks)

      return render_status("running", tasks=tasks)

  

  
@@ -30,12 +47,23 @@ 

  def importing():

      tasks = builds_logic.BuildsLogic.get_build_importing_queue(background=False).all()

      bg_tasks_cnt = builds_logic.BuildsLogic.get_build_importing_queue(background=True).count()

+     tasks = list(zip(["rpm"] * len(tasks),

+                      [x.submitted_on for x in tasks],

+                      tasks))

      return render_status("importing", tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)

  

  

  @status_ns.route("/starting/")

  def starting():

      tasks = builds_logic.BuildsLogic.get_build_tasks(StatusEnum("starting")).all()

+     tasks = list(zip(["rpm"] * len(tasks),

+                      [x.build.submitted_on for x in tasks],

+                      tasks))

+     srpm_tasks = builds_logic.BuildsLogic.get_srpm_build_tasks(StatusEnum("starting")).all()

+     srpm_tasks = list(zip(["srpm"] * len(srpm_tasks),

+                           [x.submitted_on for x in srpm_tasks],

+                           srpm_tasks))

+     tasks.extend(srpm_tasks)

      return render_status("starting", tasks=tasks)