Commit c290cae3 by Kálmán Viktor

dashboard: merge same activites

parent 99df6972
......@@ -6,6 +6,7 @@
</span>
<strong{% if user.is_superuser and a.result %} title="{{ a.result }}"{% endif %}>
{% if user.is_superuser %}<a href="{{ a.get_absolute_url }}">{% endif %}
{% if a.times > 1 %}({{ a.times }}x){% endif %}
{{ a.get_readable_name }}{% if user.is_superuser %}</a>{% endif %}
</strong>
{{ a.started|date:"Y-m-d H:i" }}{% if a.user %},
......
......@@ -270,7 +270,8 @@ class VmDetailView(CheckedDetailView):
})
# activity data
context['activities'] = self.object.get_activities(self.request.user)
context['activities'] = self.object.get_merged_activities(
self.request.user)
context['vlans'] = Vlan.get_objects_with_level(
'user', self.request.user
......@@ -2103,7 +2104,7 @@ def vm_activity(request, pk):
if only_status == "false": # instance activity
context = {
'instance': instance,
'activities': instance.get_activities(request.user),
'activities': instance.get_merged_activities(request.user),
'ops': get_operations(instance, request.user),
}
......
......@@ -927,6 +927,23 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
user=user)
return acts
def get_merged_activities(self, user=None):
acts = list(self.get_activities(user))
merged_acts = []
latest = None
for a in acts:
if (latest == a.activity_code and
merged_acts[-1].result == a.result and
(merged_acts[-1].finished - a.finished).days < 7):
merged_acts[-1].times += 1
else:
merged_acts.append(a)
merged_acts[-1].times = 1
latest = a.activity_code
return merged_acts
def get_screenshot(self, timeout=5):
queue_name = self.get_remote_queue_name('vm')
return vm_tasks.screenshot.apply_async(args=[self.vm_name],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment