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
Conversation
Renamed the scheduler container because it isn't used in production either. Makes sense, I think. |
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.
This is a very good start, but I think there are some things missing:
- 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.
- 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?
Also, add tests.
Also, fix a few typoes
Also, remove the ability to request statistics if the stats in the db are very recent.
ef28214
to
43302cc
Compare
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.
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') |
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.
Now that we merged the brainzutils PR, should this be updated to use brainz util caching instead?
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.
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.') |
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.
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) |
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.
time has not been imported 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.
💃 🎉 🎈
Summary
Problem
Solution
Add a stats_calculator script and send users to that queue.