feeds.py 1.24 KB
Newer Older
1
from django.contrib.syndication.views import Feed
2
3
from codespeed.models import Report
from django.conf import settings
4
from django.db.models import Q
Miquel Torres's avatar
Miquel Torres committed
5

Miquel Torres's avatar
Miquel Torres committed
6

7
class ResultFeed(Feed):
8
    title = settings.WEBSITE_NAME
Miquel Torres's avatar
Miquel Torres committed
9
    link = "/changes/"
Chris Adams's avatar
Chris Adams committed
10

Miquel Torres's avatar
Miquel Torres committed
11
    def items(self):
12
13
14
        return Report.objects\
            .filter(self.result_filter())\
            .order_by('-revision__date')[:10]
15

16
    def item_title(self, item):
Miquel Torres's avatar
Miquel Torres committed
17
18
        return "%s: %s" % (item.revision.get_short_commitid(),
                           item.item_description())
19
20
21
22
23
24
25
26

    description_template = "codespeed/changes_table.html"

    def get_context_data(self, **kwargs):
        report = kwargs['item']
        trendconfig = settings.TREND

        tablelist = report.get_changes_table(trendconfig)
27

28
29
30
31
32
33
34
        return {
            'tablelist': tablelist,
            'trendconfig': trendconfig,
            'rev': report.revision,
            'exe': report.executable,
            'env': report.environment,
        }
35

Miquel Torres's avatar
Miquel Torres committed
36

37
class LatestEntries(ResultFeed):
38
    description = "Last Results"
39
40

    def result_filter(self):
41
        return Q()
42

Miquel Torres's avatar
Miquel Torres committed
43

44
class LatestSignificantEntries(ResultFeed):
45
    description = "Last results with significant changes"
46

47
    def result_filter(self):
48
        return Q(colorcode__in=('red', 'green'))