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

Commit fffee0b

Browse files
authored
Merge pull request #327 from wufeifei/develop
add report link on task manage
2 parents 8fa6dbd + f55be84 commit fffee0b

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

app/controller/backend/task.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
from . import ADMIN_URL
2020
from app import web, db
2121
from utils.validate import ValidateClass, login_required
22-
from app.models import CobraTaskInfo
22+
from app.models import CobraTaskInfo, CobraProjects
2323
from utils.common import convert_number, convert_time
24+
from utils import config
2425

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

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

45+
tasks_dict = []
4446
for task in all_tasks:
45-
task.file_count = convert_number(task.file_count)
46-
task.code_number = convert_number(task.code_number) if task.code_number != 0 else u"统计中..."
47-
task.time_start = datetime.datetime.fromtimestamp(task.time_start)
48-
task.time_end = datetime.datetime.fromtimestamp(task.time_end)
49-
task.time_consume = convert_time(task.time_consume)
47+
p = CobraProjects.query.with_entities(CobraProjects.id).filter(CobraProjects.repository == task.target).first()
48+
tasks_dict.append({
49+
'file_count': convert_number(task.file_count),
50+
'code_number': convert_number(task.code_number) if task.code_number != 0 else u"Statistic...",
51+
'time_start': datetime.datetime.fromtimestamp(task.time_start),
52+
'time_end': datetime.datetime.fromtimestamp(task.time_end),
53+
'time_consume': convert_time(task.time_consume),
54+
'updated_at': task.updated_at,
55+
'target': task.target,
56+
'id': task.id,
57+
'status': task.status,
58+
'pid': p.id,
59+
'report': 'http://' + config.Config('cobra', 'domain').value + '/report/' + str(p.id)
60+
})
5061

5162
if keyword == '0':
5263
keyword = ''
5364
data = {
5465
'total': total,
55-
'tasks': all_tasks,
66+
'tasks': tasks_dict,
5667
'page': page,
5768
'keyword': keyword
5869
}

app/templates/backend/task/tasks.html

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<table class="cl" data-sort="table">
1717
<thead>
1818
<tr>
19+
<th>PID</th>
1920
<th>TID</th>
2021
<th>Target</th>
2122
<th>Consume</th>
@@ -32,6 +33,7 @@
3233
{% endif %}
3334
{% for task in data.tasks %}
3435
<tr>
36+
<td><a href="{{ task.report }}" target="_blank">{{ task.pid }}</a></td>
3537
<td>{{ task.id }}</td>
3638
<td id="task-target-{{ task.id }}">{{ task.target }}</td>
3739
<td align="center" id="task-time-consume-{{ task.time_consume }}">{{ task.time_consume }}</td>

0 commit comments

Comments
 (0)