|
1 | 1 | from django.contrib.syndication.views import Feed |
2 | 2 | from codespeed.models import Report |
3 | 3 | from django.conf import settings |
| 4 | +from django.db.models import Q |
4 | 5 |
|
5 | | - |
6 | | -class LatestEntries(Feed): |
| 6 | +class ResultFeed(Feed): |
7 | 7 | title = settings.WEBSITE_NAME |
8 | 8 | link = "/changes/" |
9 | | - description = "Last benchmark runs" |
10 | 9 |
|
11 | 10 | 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] |
15 | 14 |
|
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): |
19 | 22 | description = "Last significant benchmark runs" |
20 | 23 |
|
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