Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
db39311c
authored
Mar 15, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: improve node list performance
parent
36538eb0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
3 deletions
+8
-3
circle/dashboard/templates/dashboard/node-list/column-vm.html
+1
-1
circle/dashboard/views.py
+5
-1
circle/vm/models/node.py
+2
-1
No files found.
circle/dashboard/templates/dashboard/node-list/column-vm.html
View file @
db39311c
{% load i18n %}
<div
id=
"node-list-column-vm"
>
<a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
node-detail
"
pk=
record.pk
%}#
virtualmachines
"
>
{{
record.instance_set.count
}}
</a>
<a
class=
"real-link"
href=
"{% url "
dashboard
.
views
.
node-detail
"
pk=
record.pk
%}#
virtualmachines
"
>
{{
value
}}
</a>
</div>
circle/dashboard/views.py
View file @
db39311c
...
...
@@ -14,6 +14,7 @@ from django.core.exceptions import (
)
from
django.core
import
signing
from
django.core.urlresolvers
import
reverse
,
reverse_lazy
from
django.db.models
import
Count
from
django.http
import
HttpResponse
,
HttpResponseRedirect
,
Http404
from
django.shortcuts
import
redirect
,
render
,
get_object_or_404
from
django.views.decorators.http
import
require_GET
...
...
@@ -921,10 +922,13 @@ class VmList(LoginRequiredMixin, SingleTableView):
class
NodeList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/node-list.html"
model
=
Node
table_class
=
NodeListTable
table_pagination
=
False
def
get_queryset
(
self
):
return
Node
.
objects
.
annotate
(
number_of_VMs
=
Count
(
'instance_set'
))
.
select_related
(
'host'
)
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
template_name
=
"dashboard/group-list.html"
...
...
circle/vm/models/node.py
View file @
db39311c
...
...
@@ -305,7 +305,8 @@ class Node(TimeStampedModel):
@classmethod
def
get_state_count
(
cls
,
online
,
enabled
):
return
len
([
1
for
i
in
cls
.
objects
.
filter
(
enabled
=
enabled
)
.
all
()
return
len
([
1
for
i
in
cls
.
objects
.
filter
(
enabled
=
enabled
)
.
select_related
(
'host'
)
if
i
.
online
==
online
])
@permalink
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment