File tree 2 files changed +1
-17
lines changed
2 files changed +1
-17
lines changed Original file line number Diff line number Diff line change 1
1
import ast
2
2
import calendar
3
3
import datetime
4
- import operator
5
- from functools import reduce
6
4
7
5
import requests
8
6
from django .contrib .contenttypes .fields import GenericForeignKey , GenericRelation
@@ -254,17 +252,6 @@ def link(self):
254
252
return self .urljoin (self .jenkins_root_url , "job" , self .build_name )
255
253
256
254
257
- class DatumQuerySet (models .QuerySet ):
258
- def metrics (self , * metrics ):
259
- """
260
- Return only the data from the given metrics.
261
- """
262
- if not metrics :
263
- return self .none ()
264
- qobjs = [models .Q (content_type = m .content_type , object_id = m .pk ) for m in metrics ]
265
- return self .filter (reduce (operator .or_ , qobjs ))
266
-
267
-
268
255
class Datum (models .Model ):
269
256
metric = GenericForeignKey ()
270
257
content_type = models .ForeignKey (
@@ -274,8 +261,6 @@ class Datum(models.Model):
274
261
timestamp = models .DateTimeField (default = datetime .datetime .now )
275
262
measurement = models .BigIntegerField ()
276
263
277
- objects = DatumQuerySet .as_manager ()
278
-
279
264
class Meta :
280
265
ordering = ["-timestamp" ]
281
266
get_latest_by = "timestamp"
Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ def index(request):
25
25
metrics = sorted (metrics , key = operator .attrgetter ("display_position" ))
26
26
27
27
metric_latest_querysets = [
28
- Datum .objects .metrics (metric ).order_by ("-timestamp" )[0 :1 ]
29
- for metric in metrics
28
+ metric .data .order_by ("-timestamp" )[0 :1 ] for metric in metrics
30
29
]
31
30
data_latest = Datum .objects .none ().union (* metric_latest_querysets )
32
31
latest_by_metric = {
You can’t perform that action at this time.
0 commit comments