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

scores: Enable automatic refreshing (every 30s for now) of scores.json. #281

Merged
merged 8 commits into from Oct 28, 2017

Conversation

poelstra
Copy link
Collaborator

Another part of #245: automatically refresh the scores and ranking screens.

Note: this PR only does a periodic refresh (hardcoded to 30s for now).
It does not yet refresh on e.g. an MHub message, which can be done separately.

It also doesn't yet remove the Refresh button: I think it may occassionally still be useful to manually press it if needed, but let's discuss that in a separate issue.

Advice to merge this PR after #278, to prevent people being annoyed when a refresh happens when they're editing a score.

Also fixes #115.

$scores.enableAutoRefresh();
$scores.beginupdate();
$interval.flush($scores._autoRefreshTimeout + 1);
expect(fsMock.read).not.toHaveBeenCalled();
Copy link
Member

Choose a reason for hiding this comment

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

missing a test that it should continue refreshing when no longer busy

this._autoRefreshInterval = $interval(function() {
// Reload scores from server (if we're not already
// in the middle of something).
if (self._updating <= 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Better extract a function isUpdating() that checks the _updating counter, rather than comparing the counter against 0 on several places

@rikkertkoppes
Copy link
Member

To reduce the code complexity a bit, I'd suggest to extract the 3 methods to something generic and external to the module. Basically is is a fancy $interval service that keeps track of subscriber count. The only parameters needed by this service is what to do every interval:

                if (self._updating <= 0) {
                    self.load();
                }

And the interval itself. All the rest is internal to the service

@poelstra
Copy link
Collaborator Author

poelstra commented Oct 8, 2017

@rikkertkoppes Addressed both of your remarks.

However, the tests for ng-scores now fail. Apparently, because ng-scores can't find the Poller factory, but this only happens in the tests. I've been pulling my hair out for 2 hours on this now, and can't figure out why.

I would really appreciate if you can take a look at why this may be happening, given that you initially set that stuff up, and are more knowledgeable on the angular side anyway...

@poelstra
Copy link
Collaborator Author

poelstra commented Oct 8, 2017

BTW: the conflicts are trivial to resolve: they are only marked as conflict because the lines happened to be adjacent. So keeping changes from both sides will do the trick.

@poelstra poelstra mentioned this pull request Oct 21, 2017
@poelstra
Copy link
Collaborator Author

Tests issue should be fixed by #293, will merge master into this (or rebase) after that PR is merged.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 87.74% when pulling 97e09a7 on periodic_scores_refresh into f7f3b46 on master.

@poelstra
Copy link
Collaborator Author

Appears that another dependency was missing ('services' should depend on 'factories'), which fixes the tests (even without #293). Strange that it worked in the frontend without that dependency, though...

Merged master in to resolve the merge conflicts (basically accepting the changes from both sides).

Conflicts:
	src/js/services/ng-scores.js
@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 87.873% when pulling eb4582b on periodic_scores_refresh into a243e4a on master.

@kmeesters kmeesters merged commit 05ef270 into master Oct 28, 2017
@kmeesters kmeesters deleted the periodic_scores_refresh branch October 28, 2017 18:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Refresh button on Ranking tab
4 participants