return sorted(jobs)
def get_active(self, host_id=None, uploads=True):
- running_states = ["dispatching", "running"]
+ running_states = ["dispatching", "new", "pending", "running"]
if uploads:
running_states.append("uploading")
if host_id:
query += " AND builder_id = %s" % host_id
- query += " ORDER BY time_started DESC"
+ query += " ORDER BY \
+ CASE \
+ WHEN jobs.state = 'running' THEN 0 \
+ WHEN jobs.state = 'uploading' THEN 1 \
+ WHEN jobs.state = 'dispatching' THEN 2 \
+ WHEN jobs.state = 'pending' THEN 3 \
+ WHEN jobs.state = 'new' THEN 4 \
+ END, time_started ASC"
return [Job(self.pakfire, j.id, j) for j in self.db.query(query)]
return jobs
- def get_latest(self, builder=None, limit=10):
+ def get_latest(self, builder=None, limit=None, age=None, date=None):
query = "SELECT * FROM jobs"
+ args = []
- #where = ["time_finished IS NOT NULL",]
- where = ["(state = 'finished' OR state = 'failed')"]
+ where = ["(state = 'finished' OR state = 'failed' OR state = 'aborted')"]
if builder:
- where.append("builder = '%s'" % builder)
+ where.append("builder_id = %s")
+ args.append(builder.id)
+
+ if date:
+ year, month, day = date.split("-", 2)
+
+ try:
+ date = datetime.date(int(year), int(month), int(day))
+ except ValueError:
+ pass
+
+ else:
+ where.append("DATE(time_created) = %s")
+ args.append(date)
+ where.append("DATE(time_started) = %s")
+ args.append(date)
+ where.append("DATE(time_finished) = %s")
+ args.append(date)
+
+ if age:
+ where.append("time_finished >= DATE_SUB(NOW(), INTERVAL %s)" % age)
if where:
query += " WHERE %s" % " AND ".join(where)
- query += " ORDER BY time_finished DESC LIMIT %s"
+ query += " ORDER BY time_finished DESC"
+
+ if limit:
+ query += " LIMIT %s"
+ args.append(limit)
- return [Job(self.pakfire, j.id, j) for j in self.db.query(query, limit)]
+ return [Job(self.pakfire, j.id, j) for j in self.db.query(query, *args)]
def get_average_build_time(self):
"""
$(document).ready(function() {
// Activate Google Prettify for pretty-printing code.
window.prettyPrint && prettyPrint()
+
+ // Activate tooltips.
+ $("span[rel=tooltip]").tooltip();
});
function getCookie(name) {
{% else %}
<div class="hero-unit ac" style="background-color: white">
+ <br>
<h1>
- {{ _("Pakfire Build Service") }}<br>
- <small>{{ _("Development powered by community!") }}</small>
+ {{ _("Pakfire Build Service") }}
</h1>
- <br><br>
+ <hr>
- <a class="btn" href="/documents">{{ _("Learn more") }} »</a>
+ <h2>
+ <small>{{ _("Development powered by community!") }}</small>
+ </h2>
</div>
<hr>
<a href="/updates">{{ _("View more updates...") }}</a>
</p>
- <hr style="clear: both;">
+ <br style="clear: both;">
</div>
</div>
{% end %}
- <div class="row">
- <div class="span6">
- {% if active_jobs %}
- <h3>
- {{ _("Ongoing build jobs") }}
- <small>({{ len(active_jobs) }})</small>
- </h3>
- {% module JobsList(active_jobs, show_builder=True) %}
- {% end %}
+ {% if jobs %}
+ <hr>
- <a href="/builds/queue">
- {% if job_queue %}
- {{ _("There is one job in the job queue.", "There are %(num)s jobs in the job queue.", job_queue) % { "num" : job_queue } }}
- {% else %}
- {{ _("There are no jobs in the job queue.") }}
- {% end %}
- </a>
- </div>
+ <h4>{{ _("Build jobs") }}</h4>
+ {% module JobsList(jobs) %}
+ {% end %}
- <div class="span6">
- <h3>{{ _("Lately processed jobs") }}</h3>
- {% module JobsList(latest_jobs) %}
- </div>
- </div>
+ <a href="/jobs">{{ _("Show more build jobs") }}</a>
{% end %}
+++ /dev/null
-{% if jobs %}
- <table class="table table-striped table-hover">
- {% for job in jobs %}
- <tr {% if job.state in ("aborted", "failed") %}class="error"{% end %}>
- <td>
- {% if job.state == "dispatching" %}
- <i class="icon-chevron-left"></i>
- {% elif job.state == "running" %}
- <i class="icon-retweet"></i>
- {% elif job.state == "finished" %}
- <i class="icon-ok"></i>
- {% elif job.state == "dependency_error" %}
- <i class="icon-random"></i>
- {% elif job.state == "failed" %}
- <i class="icon-remove"></i>
- {% elif job.state == "uploading" %}
- <i class="icon-chevron-right"></i>
- {% elif job.state == "aborted" %}
- <i class="icon-warning-sign"></i>
- {% end %}
-
- <a href="/build/{{ job.build.uuid }}">
- {{ job.build.name }}</a>.<a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
-
- {% if job.build.type == "scratch" %}
- <span class="label label-inverse">S</span>
- {% elif job.type == "test" %}
- <span class="label label-inverse">T</span>
- {% end %}
-
- {% if show_builder and job.builder %}
- <br />
- {{ _("Builder") }}:
- <a href="/builder/{{ job.builder.name }}">
- {{ job.builder.name }}
- </a>
- {% end %}
- </td>
- </tr>
- {% end %}
- </table>
-{% else %}
- {{ _("No jobs to display.") }}
-{% end %}
--- /dev/null
+<table class="table table-striped table-hover">
+ <thead>
+ <tr>
+ <th></th>
+ <th>{{ _("Build job") }}</th>
+ <th>{{ _("Builder") }}</th>
+ <th>{{ _("Runtime") }}</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {% for job in jobs %}
+ {% if job.state in ("running",) %}
+ <tr class="success">
+ {% elif job.state in ("dispatching", "uploading") %}
+ <tr class="info">
+ {% elif job.state in ("aborted", "dependency_error", "failed") %}
+ <tr class="error">
+ {% else %}
+ <tr>
+ {% end %}
+
+ <td>
+ {% module JobState(job, show_icon=True) %}
+ </td>
+
+ <td>
+ <a href="/build/{{ job.build.uuid }}">
+ {{ job.build.name }}</a>.<a href="/job/{{ job.uuid }}">{{ job.arch.name }}</a>
+
+ {% if job.build.type == "scratch" %}
+ <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Scratch build") }}">S</span>
+ {% elif job.type == "test" %}
+ <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Test build") }}">T</span>
+ {% end %}
+ </td>
+
+ <td>
+ {% if job.builder %}
+ <a href="/builder/{{ job.builder.name }}">
+ {{ job.builder.name }}
+ </a>
+ {% else %}
+ {{ _("N/A") }}
+ {% end %}
+ </td>
+
+ <td>
+ {{ friendly_time(job.duration) }}
+ </td>
+ </tr>
+ {% end %}
+ </tbody>
+</table>
"Changelog" : ChangelogModule,
"ChangelogEntry" : ChangelogEntryModule,
+ # Jobs
+ "JobsList" : JobsListModule,
+
# Packages
"PackagesDependencyTable" : PackagesDependencyTableModule,
"JobsBoxes" : JobsBoxesModule,
"JobState" : JobStateModule,
"JobsTable" : JobsTableModule,
- "JobsList" : JobsListModule,
"CommentsTable" : CommentsTableModule,
"FilesTable" : FilesTableModule,
"LogTable" : LogTableModule,
class IndexHandler(BaseHandler):
def get(self):
- kwargs = {
- "active_jobs" : self.pakfire.jobs.get_active(),
- "latest_jobs" : self.pakfire.jobs.get_latest(limit=10),
-
- "job_queue" : self.pakfire.jobs.count("pending"),
- }
+ jobs = self.pakfire.jobs.get_active()
+ jobs += self.pakfire.jobs.get_latest(age="24 HOUR", limit=5)
# Updates
updates = []
updates.append((type, u, active))
active = False
- kwargs["updates"] = updates
-
- self.render("index.html", **kwargs)
+ self.render("index.html", jobs=jobs, updates=updates)
class Error404Handler(BaseHandler):
class JobsListModule(UIModule):
- def render(self, jobs, show_builder=False):
- return self.render_string("modules/jobs-list.html", jobs=jobs,
- show_builder=show_builder)
+ def render(self, jobs):
+ return self.render_string("modules/jobs/list.html", jobs=jobs)
class RepositoryTableModule(UIModule):