[datafeed] simplify SQL query used to retrieve information about entities from an external source
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 01 Jul 2015 08:45:29 +0200
changeset 11253 be480b9d6ee2
parent 11252 6b1d09ef0c45
child 11254 4f467683b8c9
[datafeed] simplify SQL query used to retrieve information about entities from an external source no need to join on cw_source
cubicweb/server/sources/datafeed.py
--- a/cubicweb/server/sources/datafeed.py	Wed Jul 01 08:42:44 2015 +0200
+++ b/cubicweb/server/sources/datafeed.py	Wed Jul 01 08:45:29 2015 +0200
@@ -289,11 +289,9 @@
                            eidfrom=entity.eid, rtype=attr, eidto=value)
 
     def source_uris(self, cnx):
-        sql = ('SELECT extid, eid, type FROM entities, cw_source_relation '
-               'WHERE entities.eid=cw_source_relation.eid_from '
-               'AND cw_source_relation.eid_to=%s' % self.eid)
+        sql = 'SELECT extid, eid, type FROM entities WHERE asource=%(source)s'
         return dict((self.decode_extid(uri), (eid, type))
-                    for uri, eid, type in cnx.system_sql(sql).fetchall())
+                    for uri, eid, type in cnx.system_sql(sql, {'source': self.uri}).fetchall())
 
     def init_import_log(self, cnx, import_log_eid=None, **kwargs):
         if import_log_eid is None: