File tree Expand file tree Collapse file tree 4 files changed +21
-15
lines changed
dashboards/project/rating Expand file tree Collapse file tree 4 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 24
24
25
25
26
26
@memoized
27
- def cloudkittyclient (request ):
27
+ def cloudkittyclient (request , version = '1' ):
28
28
"""Initialization of Cloudkitty client."""
29
29
cacert = getattr (settings , 'OPENSTACK_SSL_CACERT' , None )
30
30
insecure = getattr (settings , 'OPENSTACK_SSL_NO_VERIFY' , False )
@@ -43,7 +43,7 @@ def cloudkittyclient(request):
43
43
}
44
44
45
45
return ck_client .Client (
46
- '1' ,
46
+ version ,
47
47
auth = auth ,
48
48
cacert = cacert ,
49
49
insecure = insecure ,
Original file line number Diff line number Diff line change 19
19
class SummaryTable (tables .DataTable ):
20
20
"""This table formats a summary for the given tenant."""
21
21
22
- res_type = tables .Column ('res_type ' , verbose_name = _ ('Metric Type' ))
22
+ res_type = tables .Column ('type ' , verbose_name = _ ('Metric Type' ))
23
23
rate = tables .Column ('rate' , verbose_name = _ ('Rate' ))
24
24
25
25
class Meta (object ):
26
26
name = "summary"
27
27
verbose_name = _ ("Summary" )
28
+
29
+ def get_object_id (self , datum ):
30
+ return datum .get ('type' )
Original file line number Diff line number Diff line change 22
22
from cloudkittydashboard .api import cloudkitty as api
23
23
from cloudkittydashboard .dashboards .project .rating \
24
24
import tables as rating_tables
25
- from cloudkittydashboard .utils import TemplatizableDict
26
25
27
26
28
27
class IndexView (tables .DataTableView ):
29
28
table_class = rating_tables .SummaryTable
30
29
template_name = 'project/rating/index.html'
31
30
32
31
def get_data (self ):
33
- summary = api .cloudkittyclient (self .request ).report .get_summary (
34
- tenant_id = self .request .user .tenant_id ,
35
- groupby = ['tenant_id' , 'res_type' ])['summary' ]
36
- summary = api .identify (summary , key = 'res_type' , name = True )
37
- summary .append (TemplatizableDict ({
38
- 'id' : 'ALL' ,
39
- 'res_type' : 'TOTAL' ,
40
- 'name' : 'ALL' ,
41
- 'rate' : sum ([float (i ['rate' ]) for i in summary ]),
42
- }))
43
- return summary
32
+ summary = api .cloudkittyclient (
33
+ self .request , version = '2' ).summary .get_summary (
34
+ tenant_id = self .request .user .tenant_id ,
35
+ groupby = ['type' ], response_format = 'object' )
36
+
37
+ data = summary .get ('results' )
38
+ total = sum ([r .get ('rate' ) for r in data ])
39
+
40
+ data .append ({'type' : 'TOTAL' , 'rate' : total })
41
+ return data
44
42
45
43
46
44
def quote (request ):
Original file line number Diff line number Diff line change
1
+ ---
2
+ other :
3
+ - |
4
+ The ratings panel in the project dashboard has been converted
5
+ to use the v2 API.
You can’t perform that action at this time.
0 commit comments