Rfaulk has submitted this change and it was merged.

Change subject: add. method is_item to detect key in target.
......................................................................


add. method is_item to detect key in target.

Change-Id: If95f68f751162b4b9824d0959c49d431b6cfb451
---
M user_metrics/api/broker.py
1 file changed, 14 insertions(+), 0 deletions(-)

Approvals:
  Rfaulk: Verified; Looks good to me, approved



diff --git a/user_metrics/api/broker.py b/user_metrics/api/broker.py
index b17dbfd..e5d83eb 100644
--- a/user_metrics/api/broker.py
+++ b/user_metrics/api/broker.py
@@ -65,10 +65,18 @@
         """
         raise NotImplementedError()
 
+    def is_item(self, target, key):
+        """
+        Return boolean indicating whether a key is in target
+        """
+        raise NotImplementedError()
+
 
 class FileBroker(Broker):
     """
     Implements a broker that uses a flat file as a broker
+
+    !! Operations are O(n), consider storing keys in heap
     """
 
     def __init__(self, **kwargs):
@@ -201,3 +209,9 @@
             with open(target, 'w'):
                 pass
         return None
+
+    def is_item(self, target, key):
+        """
+        Return boolean indicating whether a key is in target
+        """
+        return key in self.get_keys(target)

-- 
To view, visit https://gerrit.wikimedia.org/r/79035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If95f68f751162b4b9824d0959c49d431b6cfb451
Gerrit-PatchSet: 1
Gerrit-Project: analytics/user-metrics
Gerrit-Branch: master
Gerrit-Owner: Rfaulk <[email protected]>
Gerrit-Reviewer: Rfaulk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to