#590 [frontend] display badges in task queue tabs, see #552
Merged a year ago by msuchy. Opened a year ago by frostyx.
copr/ frostyx/copr queue-tabs-count-552  into  master

@@ -17,13 +17,22 @@ 

  <h1> Task queue </h1>

  <ul class="nav nav-tabs">

    <li class="{% block importing_selected %}{% endblock %}">

-       <a href="{{ url_for('status_ns.importing') }}">Importing</a>

+       <a href="{{ url_for('status_ns.importing') }}">

+           Importing

+           <span class="badge">{{ queue_sizes['importing'] }}</span>

+       </a>

    </li>

    <li class="{% block pending_selected %}{% endblock %}">

-       <a href="{{ url_for('status_ns.pending') }}">Pending</a>

+       <a href="{{ url_for('status_ns.pending') }}">

+           Pending

+           <span class="badge">{{ queue_sizes['pending'] }}</span>

+       </a>

    </li>

    <li class="{% block running_selected %}{% endblock %}">

-       <a href="{{ url_for('status_ns.running') }}">Running</a>

+       <a href="{{ url_for('status_ns.running') }}">

+           Running

+           <span class="badge">{{ queue_sizes['running'] }}</span>

+       </a>

    </li>

    <li class="{% block stats_selected %}{% endblock %}">

        <a href="{{ url_for('status_ns.stats') }}">Statistics</a>

@@ -4,6 +4,7 @@ 

  from copr_common.enums import StatusEnum

  from coprs.views.status_ns import status_ns

  from coprs.logic import builds_logic

+ from coprs.logic import complex_logic

  

  

  @status_ns.route("/")

@@ -11,27 +12,26 @@ 

  def pending():

      tasks = builds_logic.BuildsLogic.get_pending_build_tasks(background=False).limit(300).all()

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

-     return flask.render_template("status/pending.html",

-                                  number=len(tasks),

-                                  tasks=tasks, bg_tasks_cnt=bg_tasks_cnt)

+     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")).limit(300).all()

-     return flask.render_template("status/running.html",

-                                  number=len(tasks),

-                                  tasks=tasks)

+     return render_status("running", tasks=tasks)

  

  

  @status_ns.route("/importing/")

  def importing():

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

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

-     return flask.render_template("status/importing.html",

-                                  number=len(list(tasks)),

-                                  bg_tasks_cnt=bg_tasks_cnt,

-                                  tasks=tasks)

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

+ 

+ 

+ def render_status(build_status, tasks, bg_tasks_cnt=None):

+     queue_sizes = complex_logic.ComplexLogic.get_queue_sizes()

+     return flask.render_template("status/{}.html".format(build_status), number=len(tasks), tasks=tasks,

+                                  bg_tasks_cnt=bg_tasks_cnt, queue_sizes=queue_sizes)

  

  

  @status_ns.route("/stats/")