From 1e11fa0a385ea7c1a8a285348a5cfca928a112bb Mon Sep 17 00:00:00 2001 From: Schuyler Duveen Date: Tue, 30 Oct 2018 14:26:18 -0400 Subject: [PATCH] wip: getting email count of attendees --- event_exim/connectors/actionkit_api.py | 5 ++++- event_exim/models.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/event_exim/connectors/actionkit_api.py b/event_exim/connectors/actionkit_api.py index 51cb76d..6c0b0b0 100644 --- a/event_exim/connectors/actionkit_api.py +++ b/event_exim/connectors/actionkit_api.py @@ -64,7 +64,8 @@ class Connector: other_fields = ['ee.id', 'ee.creator_id', 'ee.campaign_id', 'ee.phone', 'ee.notes', 'ec.title', 'signuppage.name', 'createpage.name', 'host.id', 'hostaction.id', 'hostaction2.action_ptr_id', 'hostcreateaction.action_ptr_id', - 'u.id', 'u.first_name', 'u.last_name', 'u.email', 'loc.us_district', 'recentphone.value'] + 'u.id', 'u.first_name', 'u.last_name', 'u.email', 'loc.us_district', 'recentphone.value', + 'COUNT(emails.body_id) AS emailcount'] event_fields = ['review_status', 'prep_status', 'needs_organizer_help', 'political_scope', 'public_phone', 'venue_category'] @@ -93,6 +94,7 @@ class Connector: " LEFT JOIN core_eventsignupaction hostaction2 ON (hostaction2.signup_id = host.id)" " LEFT JOIN core_eventcreatepage cec ON (cec.campaign_id = ee.campaign_id)" " LEFT JOIN core_page createpage ON (createpage.id = cec.page_ptr_id AND createpage.hidden=0 AND createpage.status='active')" + " LEFT JOIN events_emaillog emails ON (emails.event_id = ee.id)" " %(eventjoins)s " " xxADDITIONAL_WHERExx " #will be replaced with text or empty string on run # we need to include hostcreateaction in group by so it doesn't get squashed with first match @@ -284,6 +286,7 @@ def _convert_event(self, event_rows): 'create_page': event_row[fi['createpage.name']], 'create_action_id': cohost_create_action, 'hosts': hosts, + 'emailstoattendees': event_row[fi['COUNT(emails.body_id) AS emailcount']], }), }) for df in self.date_fields: diff --git a/event_exim/models.py b/event_exim/models.py index c55cdb3..8c02121 100644 --- a/event_exim/models.py +++ b/event_exim/models.py @@ -239,6 +239,7 @@ class EventDupeGuesses(models.Model): class Meta: unique_together = (('source_event','dupe_event'),) + # TODO: reverse order by recency @staticmethod def get_potential_dupes():