Mercurial > hg > Feedworm
view backend/arangodb/FeedEntry.py @ 259:304917762618 default tip
implementation of feed updates
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 12 Mar 2019 02:41:22 +0100 |
parents | f79be01821c4 |
children |
line wrap: on
line source
# -*- coding: utf-8 -*- from datetime import datetime class FeedEntry(object): @staticmethod def find_by_link(link, database): query = """ FOR feed_entry_doc IN feed_entry FILTER feed_entry_doc.link == @link RETURN feed_entry_doc """ bind_vars = { 'link': link } results = database.AQLQuery(query, bind_vars) if len(results) > 0: return FeedEntry[results[0]] else: return None def __init__(self, document): super(FeedEntry, self).__init__() self.document = document def __getattr__(self, attribute): if attribute == 'updated' or attribute == 'created': return self._parse_date(attribute) return self.document[attribute] def _parse_date(self, attribute): value = self.document[attribute] return datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f') def markRead(self): self.document['read'] = True self.document.patch()