# HG changeset patch # User Goffi # Date 1503219587 -7200 # Node ID 516b282aa54248f6f1c51c125ec3a20aa362e4da # Parent 6d059f07c2d3af8ad0c90014b017da9ec3f614a4 backend (notifications): avoid useless database request in getNotifications diff -r 6d059f07c2d3 -r 516b282aa542 sat_pubsub/backend.py --- a/sat_pubsub/backend.py Sat Aug 12 18:29:32 2017 +0200 +++ b/sat_pubsub/backend.py Sun Aug 20 10:59:47 2017 +0200 @@ -362,7 +362,7 @@ '//event/pubsub/notify') - def getNotifications(self, nodeDbId, items_data): + def getNotifications(self, node, items_data): """Build a list of subscriber to the node subscribers will be associated with subscribed items, @@ -388,8 +388,7 @@ failure.trap(error.NodeNotFound) return [] - d1 = self.storage.getNodeById(nodeDbId) - d1.addCallback(lambda node: node.getSubscriptions('subscribed')) + d1 = node.getSubscriptions('subscribed') # FIXME: must add root node subscriptions ? # d2 = self.storage.getNode('', False) # FIXME: to check # d2.addCallback(lambda node: node.getSubscriptions('subscribed')) @@ -1124,7 +1123,7 @@ if subscription is None: - notifications = yield self.backend.getNotifications(node.nodeDbId, items_data) + notifications = yield self.backend.getNotifications(node, items_data) else: notifications = [(subscription.subscriber, [subscription], items_data)]