Adamw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/92434


Change subject: quick_autoreview only works on contacts having an email address
......................................................................

quick_autoreview only works on contacts having an email address

Change-Id: I3f4c368196bf4c8c78078a7544f00d90d1e8d51f
---
M dedupe/contact_cache.py
M dedupe/quick_autoreview.py
2 files changed, 31 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/tools 
refs/changes/34/92434/1

diff --git a/dedupe/contact_cache.py b/dedupe/contact_cache.py
index 6475875..acbd0f8 100644
--- a/dedupe/contact_cache.py
+++ b/dedupe/contact_cache.py
@@ -5,9 +5,10 @@
 from database import db
 
 class ContactCache(object):
-    def __init__(self, **kw):
+    def __init__(self, require_email=False, **kw):
         self.columns = []
         self.contacts = []
+        self.require_email = require_email
 
     def isEmpty(self):
         return not self.contacts.empty()
@@ -59,6 +60,10 @@
             "civicrm_country country ON address.country_id = country.id",
             "civicrm_state_province state ON address.state_province_id = 
state.id",
         ]
+        if self.require_email:
+            query.where.extend([
+                "email.email IS NOT NULL",
+            ])
         query.group_by = [
             "contact.id",
         ]
diff --git a/dedupe/quick_autoreview.py b/dedupe/quick_autoreview.py
index 7f75ac0..b275e97 100755
--- a/dedupe/quick_autoreview.py
+++ b/dedupe/quick_autoreview.py
@@ -22,7 +22,8 @@
     def __init__(self):
         self.contactCache = TaggedGroup(
             tag=Autoreview.REVIEW,
-            excludetag=QuickAutoreview.QUICK_REVIEWED
+            excludetag=QuickAutoreview.QUICK_REVIEWED,
+            require_email=True
         )
         job = ReviewJob("Quick autoreview")
         self.job_id = job.id
@@ -34,32 +35,30 @@
 
         self.contactCache.fetch()
         for contact in self.contactCache.contacts:
-            if not contact['email']:
-                continue
+            if contact['email']:
+                query = db.Query()
+                query.columns = [
+                    'MIN(contact_id) AS contact_id',
+                ]
+                query.tables = [
+                    'civicrm_email',
+                ]
+                query.where.extend([
+                    'email = %(email)s',
+                    'contact_id < %(new_id)s',
+                ])
+                query.group_by.extend([
+                    'email',
+                ])
+                query.params = {
+                    'new_id': contact['id'],
+                    'email': contact['email'],
+                }
+                result = db.get_db().execute(query)
 
-            query = db.Query()
-            query.columns = [
-                'MIN(contact_id) AS contact_id',
-            ]
-            query.tables = [
-                'civicrm_email',
-            ]
-            query.where.extend([
-                'email = %(email)s',
-                'contact_id < %(new_id)s',
-            ])
-            query.group_by.extend([
-                'email',
-            ])
-            query.params = {
-                'new_id': contact['id'],
-                'email': contact['email'],
-            }
-            result = db.get_db().execute(query)
-
-            if result:
-                for row in result:
-                    ReviewQueue.addMatch(self.job_id, row['contact_id'], 
contact['id'], Autoreview.REC_DUP, matchDescription)
+                if result:
+                    for row in result:
+                        ReviewQueue.addMatch(self.job_id, row['contact_id'], 
contact['id'], Autoreview.REC_DUP, matchDescription)
 
             ReviewQueue.tag(contact['id'], QuickAutoreview.QUICK_REVIEWED)
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f4c368196bf4c8c78078a7544f00d90d1e8d51f
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/tools
Gerrit-Branch: master
Gerrit-Owner: Adamw <[email protected]>

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

Reply via email to