Commit c9fb6fa1 authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

blog datafeed parser returns stats

parent 6404e2ef309b
......@@ -179,15 +179,18 @@ if DataFeedParser is not None:
entity_type = 'BlogEntry'
def process(self, url):
stats = {'update':0, 'creation':0}
for item in self.parse(url):
author = item.pop('author', None)
avatar = item.pop('avatar', None)
euri = self.sget_entity('ExternalUri', uri=item.pop('uri'))
if euri.same_as:
stats['update'] += 1
post = self.update_blogpost(euri.same_as[0], item)
stats['creation'] += 1
post = self.create_blogpost(item, euri)
if author:
account = self.sget_entity('UserAccount', name=author)
......@@ -195,7 +198,8 @@ if DataFeedParser is not None:
if avatar:
auri = self.sget_entity('ExternalUri', uri=avatar)
self.sget_relation(account.eid, 'has_avatar', auri.eid)
return stats
def create_blogpost(self, item, uri):
entity = self._cw.create_entity(self.entity_type, **item)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment