Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #327 from wufeifei/develop
Browse files Browse the repository at this point in the history
add report link on task manage
  • Loading branch information
FeeiCN authored Feb 16, 2017
2 parents 8fa6dbd + f55be84 commit fffee0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 18 additions & 7 deletions app/controller/backend/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
from . import ADMIN_URL
from app import web, db
from utils.validate import ValidateClass, login_required
from app.models import CobraTaskInfo
from app.models import CobraTaskInfo, CobraProjects
from utils.common import convert_number, convert_time
from utils import config

__author__ = "lightless"
__email__ = "[email protected]"
Expand All @@ -41,18 +42,28 @@ def tasks(page, keyword):

total = CobraTaskInfo.query.filter(filter_group).count()

tasks_dict = []
for task in all_tasks:
task.file_count = convert_number(task.file_count)
task.code_number = convert_number(task.code_number) if task.code_number != 0 else u"统计中..."
task.time_start = datetime.datetime.fromtimestamp(task.time_start)
task.time_end = datetime.datetime.fromtimestamp(task.time_end)
task.time_consume = convert_time(task.time_consume)
p = CobraProjects.query.with_entities(CobraProjects.id).filter(CobraProjects.repository == task.target).first()
tasks_dict.append({
'file_count': convert_number(task.file_count),
'code_number': convert_number(task.code_number) if task.code_number != 0 else u"Statistic...",
'time_start': datetime.datetime.fromtimestamp(task.time_start),
'time_end': datetime.datetime.fromtimestamp(task.time_end),
'time_consume': convert_time(task.time_consume),
'updated_at': task.updated_at,
'target': task.target,
'id': task.id,
'status': task.status,
'pid': p.id,
'report': 'http://' + config.Config('cobra', 'domain').value + '/report/' + str(p.id)
})

if keyword == '0':
keyword = ''
data = {
'total': total,
'tasks': all_tasks,
'tasks': tasks_dict,
'page': page,
'keyword': keyword
}
Expand Down
2 changes: 2 additions & 0 deletions app/templates/backend/task/tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<table class="cl" data-sort="table">
<thead>
<tr>
<th>PID</th>
<th>TID</th>
<th>Target</th>
<th>Consume</th>
Expand All @@ -32,6 +33,7 @@
{% endif %}
{% for task in data.tasks %}
<tr>
<td><a href="{{ task.report }}" target="_blank">{{ task.pid }}</a></td>
<td>{{ task.id }}</td>
<td id="task-target-{{ task.id }}">{{ task.target }}</td>
<td align="center" id="task-time-consume-{{ task.time_consume }}">{{ task.time_consume }}</td>
Expand Down

0 comments on commit fffee0b

Please sign in to comment.