Skip to content

Commit 9014aa6

Browse files
committed
Refactor feed generation a bit
1 parent 248fb36 commit 9014aa6

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

codespeed/feeds.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
from django.contrib.syndication.views import Feed
22
from codespeed.models import Report
33
from django.conf import settings
4+
from django.db.models import Q
45

5-
6-
class LatestEntries(Feed):
6+
class ResultFeed(Feed):
77
title = settings.WEBSITE_NAME
88
link = "/changes/"
9-
description = "Last benchmark runs"
109

1110
def items(self):
12-
return Report.objects.filter(
13-
revision__branch__name=settings.DEF_BRANCH
14-
).order_by('-revision__date')[:10]
11+
return Report.objects\
12+
.filter(self.result_filter())\
13+
.order_by('-revision__date')[:10]
1514

16-
class LatestSignificantEntries(Feed):
17-
title = settings.WEBSITE_NAME
18-
link = "/changes/"
15+
class LatestEntries(ResultFeed):
16+
description = "Last benchmark runs"
17+
18+
def result_filter(self):
19+
return Q(revision__branch__name=settings.DEF_BRANCH)
20+
21+
class LatestSignificantEntries(ResultFeed):
1922
description = "Last significant benchmark runs"
2023

21-
def items(self):
22-
return Report.objects.filter(
23-
revision__branch__name=settings.DEF_BRANCH,
24-
colorcode__in = ('red','green')
25-
).order_by('-revision__date')[:10]
24+
def result_filter(self):
25+
return Q(revision__branch__name=settings.DEF_BRANCH,
26+
colorcode__in = ('red','green'))

0 commit comments

Comments
 (0)