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

Make PackageDownloadsDetail and PackageDownloadsByVersion graphs update without refreshing the page #3951

Merged
merged 7 commits into from
May 12, 2017

Conversation

scottbommarito
Copy link
Contributor

@scottbommarito scottbommarito commented May 11, 2017

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).

//
// GET: /stats/packages/{id}/{version}

public virtual async Task<ActionResult> PackageDownloadsDetail(string id, string version, string[] groupby)
Copy link
Contributor

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.

Copy link
Contributor Author

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

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

Copy link
Contributor Author

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);
Copy link
Member

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)?

Copy link
Contributor Author

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);
});
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, query can change.

Copy link
Member

@xavierdecoster xavierdecoster left a 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

Copy link
Member

@joelverhagen joelverhagen left a 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();
Copy link
Contributor

Choose a reason for hiding this comment

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

var?

Copy link
Contributor Author

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

@scottbommarito scottbommarito merged commit 319bc79 into dev May 12, 2017
@scottbommarito scottbommarito deleted the sb-statsajax branch May 12, 2017 19:42
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.

7 participants