Skip to content
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

Merged
merged 1 commit into from
Apr 19, 2017
Merged

improve metrics #77

merged 1 commit into from
Apr 19, 2017

Conversation

kentwills
Copy link
Contributor

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.

@kentwills kentwills self-assigned this Apr 16, 2017
Copy link
Contributor

@ajm188 ajm188 left a 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.


metrics = defaultdict(set)
for subscription in subscriptions:
metrics[subscription.key.urlsafe()] = []
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#81

Copy link
Contributor

@ajm188 ajm188 left a 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 😛

@kentwills kentwills merged commit 5b1ab35 into Yelp:master Apr 19, 2017
@kentwills kentwills deleted the metrics branch October 14, 2017 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants