Encapsulate calls to perfherder api's inside a model

RESOLVED DUPLICATE of bug 1261176

Status

Tree Management
Perfherder
RESOLVED DUPLICATE of bug 1261176
3 years ago
2 years ago

People

(Reporter: wlach, Unassigned)

Tracking

Details

We should create a model to access the perfherder REST api's, instead of calling them directly. 

This bug will encapsulate doing this for everything, but to start with, let's create a model (let's just call it PhModel) with a getSignatureProperties(projectName, signatures) method to get the properties for a list of signatures.

There are currently two calls to this API:

https://github.com/mozilla/treeherder-ui/blob/master/webapp/app/js/perf.js#L386
https://github.com/mozilla/treeherder-ui/blob/master/webapp/app/js/perf.js#L539

Let's start with putting it inline in perf.js. We might want to break it out later so other parts of Treeherder can use it.

After this is done, we can do the same thing for get_performance_data and get_performance_series_summary, probably as part of the same model.
Ok, so we actually did wind up doing the original suggestion (https://github.com/mozilla/treeherder/blob/master/ui/js/perf.js#L67), however there are still some raw $http calls which we could encapsulate for later reuse in the graphs API.

For example, we have a call to the get_performance_data endpoint here:

https://github.com/mozilla/treeherder/blob/master/ui/js/graphs.js#L448

Let's create a method in PhSeries called getPerformanceData which takes the signature, project, and time interval as parameters and parses out the blob object returned. We can add it to the existing PhSeries factory, probably somewhere like here:

https://github.com/mozilla/treeherder/blob/master/ui/js/perf.js#L169

Follow the example of some of the other methods. Basically, you want something like:

function getPerformanceData(projectName, signature timeRange) {
  return $http.get(thServiceDomain + '/api/project/' +
            projectName + '/performance-data/0/get_performance_data/' +
            '?interval_seconds=' + timeRange +
            '&signatures=' + signature).then(function(response) {
    return response.data[0].blob;
  });
}

(this is untested, there are probably a few mistakes you'll need to correct) :)

Once you've done that, try your hand at creating a getSignatureProperties (using the same principles) to replace the $http call here:

https://github.com/mozilla/treeherder/blob/master/ui/js/graphs.js#L484
This was pretty much covered in bug 1261176
Assignee: vykuntamsrinivas → nobody
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1261176
You need to log in before you can comment on or make changes to this bug.