Mercurial > hg > Feedworm
comparison backend/arangodb/Feed.py @ 256:f79be01821c4
Arangodb backend, first version which barely works for reading
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Wed, 30 Jan 2019 07:11:10 +0100 |
parents | |
children | 304917762618 |
comparison
equal
deleted
inserted
replaced
255:b4c83e9b9c7a | 256:f79be01821c4 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from datetime import datetime | |
4 | |
5 class Feed(object): | |
6 def __init__(self, document): | |
7 super(Feed, self).__init__() | |
8 self.document = document | |
9 | |
10 def __getattr__(self, attribute): | |
11 return self.document[attribute] | |
12 | |
13 @staticmethod | |
14 def get_unread(database): | |
15 query = """ | |
16 FOR feed_entry_doc IN feed_entry | |
17 FOR feed_doc IN feed | |
18 FILTER feed_entry_doc.read == false | |
19 AND feed_entry_doc.feed == feed_doc._key | |
20 RETURN DISTINCT feed_doc""" | |
21 results = database.AQLQuery(query) | |
22 return [Feed(doc) for doc in results] | |
23 | |
24 @staticmethod | |
25 def all_pending_update(database): | |
26 query = """ | |
27 FOR feed_doc IN feed | |
28 FILTER DATE_ISO8601(DATE_NOW()) > feed_doc.next_update | |
29 RETURN feed_doc | |
30 """ | |
31 results = database.AQLQuery(query) | |
32 return [Feed(doc) for doc in results] |