-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve metrics #77
improve metrics #77
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python side looks mostly good. One comment and one question.
yelp_beans/logic/metrics.py
Outdated
|
||
metrics = defaultdict(set) | ||
for subscription in subscriptions: | ||
metrics[subscription.key.urlsafe()] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since metrics
is a defaultdict
, why do we need this initialization code here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two types of subscriptions. One with users and one without. The second for-loop doesn't populate subscriptions without users because it iterates through users. The for-loop you commented on specifically ensures that even subscriptions with no users are represented in the data structure.
This isn't too straightforward, maybe it should have a comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd like to see a brief comment here. I definitely see a future where I come in and try to delete this bit of code 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajm188 comments added
@@ -15,31 +15,40 @@ def test_get_metrics(app, minimal_database): | |||
response = metrics_api() | |||
assert response == '[]' | |||
|
|||
MeetingSubscription(title='test1').put() | |||
new_subscription = MeetingSubscription(title='test1') | |||
new_subscription.put() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker, but just had this thought: is there a way we can make sure tests clean up after themselves easily?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajm188 Ah good old test pollution, seems like we should maybe create an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python looks good to me, no comments on the js 😛
Fixes #48. Subscription counts only unique users now. In addition, this gives a count for current week participation.
The logic is cleaned up a bit as well, though this isn't the most efficient way of doing this metric. In the future, we would probably want to add some fields to the database to eliminate having to query the entire DB for some of these metrics.