1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
from . import data
from .web import Difftable
from ll.xist import xsc, parse
from ll.xist.ns import xml, rss20
def rss():
versions = data.Version.raw("""\
SELECT *
FROM version v
WHERE EXISTS (SELECT 1
FROM version v2
WHERE v2.id != v.id
AND v2.item_id == v.item_id
AND v2.created_date < v.created_date)
ORDER BY v.created_date DESC
LIMIT 30""")
items = []
for to_version in versions:
from_version = data.Version.select() \
.where((data.Version.id != to_version.id) &
(data.Version.item == to_version.item) &
(data.Version.created_date < to_version.created_date)) \
.order_by(data.Version.created_date.desc()) \
.first()
difftable = Difftable(to_version, from_version,
inline_style=True).string("utf-8")
items.append(rss20.item(
rss20.title(
"{} - {}".format(to_version.item.feed.title, to_version.title)),
rss20.author(to_version.authors),
rss20.pubDate(to_version.created_date.strftime(
"%a, %d %b %Y %T %z")),
rss20.guid("from={},to={}".format(from_version.id, to_version.id)),
rss20.link(to_version.url),
rss20.description(
xsc.Text(difftable)
)
))
return xsc.Frag(xml.XML(), rss20.rss(
rss20.channel(
rss20.title("Watchnews change report"),
*items
)
)
).string("utf-8")
|