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

LB-323: Allow users to request statistics calculation #369

Merged
merged 16 commits into from Mar 8, 2018

Conversation

paramsingh
Copy link
Collaborator

Summary

  • This is a…
    • Bug fix
    • Feature addition
    • Refactoring
    • Minor / simple change (like a typo)
    • Other

Problem

  • JIRA ticket (optional): LB-323

Solution

Add a stats_calculator script and send users to that queue.

@paramsingh
Copy link
Collaborator Author

Renamed the scheduler container because it isn't used in production either. Makes sense, I think.

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

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

This is a very good start, but I think there are some things missing:

  1. Messages talk about "next interval", but provide no details on how long an interval is or when the next one would start. It might be nice to state when the next interval starts, or at the very least state what the schedule is.
  2. Once a user gets added to the queue for calculating stats, there is no way for them to know they've been added. They could also request to calculate stats again, which is no big deal, since the second request would be ignored. But this is a bad user experience. How could we give the user feedback that they are in the queue? Maybe tell them how many people are in the queue ahead of them?

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

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

Almost there.

queue=current_app.config['STATS_QUEUE'],
error_msg='Could not put user %s into statistics calculation queue, please try again later',
)
_redis.redis.set(construct_stats_queue_key(current_user.musicbrainz_id), 'queued')
Copy link
Member

Choose a reason for hiding this comment

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

Now that we merged the brainzutils PR, should this be updated to use brainz util caching instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This isn't exactly caching which is why I used our RedisConnection directly similar to how we use it for storing now_playing listens.

flash.info('You have already been added to the stats calculation queue! Please check back later.')
elif db_stats.valid_stats_exist(current_user.id):
flash.info('Your stats were calculated in the most recent stats calculation interval,'
' please wait until the next interval! We calculate new statistics every Monday at 00:00 UTC.')
Copy link
Member

Choose a reason for hiding this comment

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

This is good, but out of date the second we change the cronjob. I think we should improve this in the future, but roll with it for now.

# if no bigquery support, sleep
if not self.app.config['WRITE_TO_BIGQUERY']:
while True:
time.sleep(10000)
Copy link
Member

Choose a reason for hiding this comment

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

time has not been imported here.

Copy link
Member

@mayhem mayhem left a comment

Choose a reason for hiding this comment

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

💃 🎉 🎈

@mayhem mayhem merged commit 35313a6 into metabrainz:master Mar 8, 2018
@paramsingh paramsingh deleted the request-stats branch March 8, 2018 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants