Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Use a separate class level variable for the contact key to use as a l…
Browse files Browse the repository at this point in the history
…ookup for subscription metrics
  • Loading branch information
justinvdm committed Nov 12, 2013
1 parent d07691a commit 8ce89e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/apps/subscription/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


class SubscriptionMetric(ConversationMetric):
CONTACT_LOOKUP_KEY = None

def __init__(self, conv, campaign_name):
self.campaign_name = campaign_name
metric_name = self.make_metric_name(campaign_name)
Expand All @@ -15,14 +17,16 @@ def get_value(self, vumi_app, user_api):
contacts = user_api.contact_store.contacts
search = contacts.raw_search(
"subscription-%s:%s" %
(self.campaign_name, self.METRIC_NAME))
(self.campaign_name, self.CONTACT_LOOKUP_KEY))

return search.get_count()


class SubscribedMetric(SubscriptionMetric):
METRIC_NAME = 'subscribed'
CONTACT_LOOKUP_KEY = 'subscribed'


class UnsubscribedMetric(SubscriptionMetric):
METRIC_NAME = 'unsubscribed'
CONTACT_LOOKUP_KEY = 'unsubscribed'
1 change: 1 addition & 0 deletions go/apps/subscription/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class ToySubscriptionMetric(SubscriptionMetric):
METRIC_NAME = 'toy-subscription-metric'
CONTACT_LOOKUP_KEY = 'toy-subscription-metric'


class TestSubscriptionMetric(TxMetricTestBase):
Expand Down

0 comments on commit 8ce89e8

Please sign in to comment.