-
Notifications
You must be signed in to change notification settings - Fork 643
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
Make PackageDownloadsDetail and PackageDownloadsByVersion graphs update without refreshing the page #3951
Conversation
// | ||
// GET: /stats/packages/{id}/{version} | ||
|
||
public virtual async Task<ActionResult> PackageDownloadsDetail(string id, string version, string[] groupby) |
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.
please add UTs for the new endpoints.
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.
done
// | ||
// GET: /stats/reports/packages/{id} | ||
|
||
public virtual async Task<JsonResult> PackageDownloadsByVersionReport(string id, string[] groupby) |
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.
consider adding basic functional tests to check those endpoints
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.
Existing functional tests have been adapted to check these new endpoints.
|
||
public virtual async Task<JsonResult> PackageDownloadsDetailReport(string id, string version, string[] groupby) | ||
{ | ||
var report = await GetPackageDownloadsDetailReport(id, version, groupby); |
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.
Should the new methods also check if (_statisticsService == NullStatisticsService.Instance)?
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.
will add
|
||
$('#statistics-retry').click(function () { | ||
renderGraph(baseUrl, query); | ||
}); |
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.
Does it need to register a new click callback on every failure?
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.
Yes, query
can change.
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.
🚀 LGTM. Linked issue #2561
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.
Nice!
@@ -158,6 +158,63 @@ public StatisticsController(IStatisticsService statisticsService, IAggregateStat | |||
return new HttpStatusCodeResult(HttpStatusCode.NotFound); | |||
} | |||
|
|||
var report = await GetPackageDownloadsByVersionReport(id, groupby); | |||
|
|||
StatisticsPackagesViewModel model = new StatisticsPackagesViewModel(); |
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.
var?
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.
was existing code, but i'll fix
This is an accessibility fix that has developed into a user experience improvement in general.
Previously, the PackageDownloadsDetail and PackageDownloadsByVersion pages would refresh every time the selected dimensions were changed. This was obviously bad for accessibility, as the focus would be lost every time the page refreshed, which disorients users.
I have fixed this.
Previously, the logic to inflate the table of information used by the browser was done in CSHTML, which is created server side. This logic is now done in JS using knockout (see
_PivotTable.cshtml
). We already had knockout in our project so I used the existing version.Added a route that returns the statistics report in JSON.
Clicking upon a checkbox now makes an AJAX call that, on success, reinflates the information table using the statistics report in JSON. On error, it shows a message that asks the user if they would like to try again, which can be clicked to retry the AJAX call.
Tested on all the major browsers (
Firefox
,Chrome
,Edge
).