perf: update report

pull/15042/head
ibuler 2025-03-14 15:32:06 +08:00
parent f513eb62a6
commit 44a3815044
3 changed files with 20 additions and 8 deletions

View File

@ -63,8 +63,8 @@ class CheckAccountExecutionViewSet(AutomationExecutionViewSet):
if not asset_id:
return Response(status=400, data={"asset_id": "This field is required."})
get_object_or_404(Asset, pk=asset_id)
name = "Check asset risk: {}".format(asset_id)
asset = get_object_or_404(Asset, pk=asset_id)
name = "Check asset risk: {}".format(asset.name)
execution = AutomationExecution()
execution.snapshot = {
"assets": [asset_id],

View File

@ -31,27 +31,35 @@
<div class="item">
<span class="item-label">{% trans 'Weak password' %}</span>
<span class="item-value">{{ summary.weak_password | default:0 }}</span>
<span class="item-value{% if summary.weak_password > 0 %} red{% endif %}">
{{ summary.weak_password | default:0 }}
</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Leaked password' %}</span>
<span class="item-value">{{ summary.leaked_password | default:0 }}</span>
<span class="item-value {% if summary.leaked_password > 0 %} red {% endif %}">
{{ summary.leaked_password | default:0 }}
</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Repeated password' %}</span>
<span class="item-value">{{ summary.repeated_password | default:0 }}</span>
<span class="item-value {% if summary.repeated_password > 0 %} red {% endif %}">
{{ summary.repeated_password | default:0 }}
</span>
</div>
<div class="item">
<span class="item-label">{% trans 'No secret' %}</span>
<span class="item-value">{{ summary.no_secret | default:0 }}</span>
<span class="item-value {% if summary.no_secret > 0 %} red {% endif %}">
{{ summary.no_secret | default:0 }}
</span>
</div>
<div class="item">
<span class="item-label">{% trans 'Task name' %}</span>
<span class="item-value">{{ execution.automation.name }}</span>
<span class="item-value">{{ execution.snapshot.name }}</span>
</div>
<div class="item">
@ -205,6 +213,9 @@
font: 500 14px/22px 'PingFang SC';
}
.container-section .item .item-value.red {
color: red;
}
.custom-table {
margin-bottom: 0;
@ -254,6 +265,7 @@
color: #2e7d32;
}
.lost-accounts .section-header span {
background: #fbe9e7;
color: #d84315;

View File

@ -116,7 +116,7 @@ class BaseManager:
automation.save(update_fields=['last_execution_date'])
def update_execution(self):
self.duration = time.time() - self.time_start
self.duration = round(time.time() - self.time_start, 2)
self.execution.date_finished = timezone.now()
self.execution.duration = self.duration
self.execution.summary = self.summary