Skip to content

Commit

Permalink
Bug 1525789 - Add commit_revision filter field to /push endpoint (#4587)
Browse files Browse the repository at this point in the history
This fixes searching for a push by a sub-commit
  • Loading branch information
Cameron Dawson committed Feb 8, 2019
1 parent fd3c52a commit b224460
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions treeherder/webapp/api/push.py
Expand Up @@ -34,7 +34,7 @@ def list(self, request, project):
meta = {}

# support ranges for date as well as revisions(changes) like old tbpl
for param in ["fromchange", "tochange", "startdate", "enddate", "revision"]:
for param in ["fromchange", "tochange", "startdate", "enddate", "revision", "commit_revision"]:
v = filter_params.get(param, None)
if v:
del filter_params[param]
Expand Down Expand Up @@ -84,15 +84,19 @@ def list(self, request, project):
"push_timestamp__lt": to_timestamp(real_end_date)
})
elif param == 'revision':
# revision can be either the revision of the push itself, or
# any of the commits it refers to
# revision must be the tip revision of the push itself
revision_field = 'revision__startswith' if len(value) < 40 else 'revision'
filter_kwargs = {revision_field: value}
pushes = pushes.filter(**filter_kwargs)
rev_key = "revisions_long_revision" \
if len(meta['revision']) == 40 else "revisions_short_revision"
filter_params.update({rev_key: meta['revision']})
self.report_if_short_revision(param, value)
elif param == 'commit_revision':
# revision can be either the revision of the push itself, or
# any of the commits it refers to
pushes = pushes.filter(commits__revision=value)
self.report_if_short_revision(param, value)

for param in ['push_timestamp__lt', 'push_timestamp__lte',
'push_timestamp__gt', 'push_timestamp__gte']:
Expand Down
6 changes: 3 additions & 3 deletions ui/js/controllers/perf/compare.js
Expand Up @@ -208,7 +208,7 @@ perf.controller('CompareResultsCtrl', [
// TODO: duplicated in comparesubtestctrl
function verifyRevision(project, revision, rsid) {

return PushModel.getList({ repo: project.name, revision })
return PushModel.getList({ repo: project.name, commit_revision: revision })
.then(async (resp) => {
if (resp.ok) {
const { results } = await resp.json();
Expand Down Expand Up @@ -351,7 +351,7 @@ perf.controller('CompareSubtestResultsCtrl', [
$httpParamSerializer) {
// TODO: duplicated from comparectrl
function verifyRevision(project, revision, rsid) {
return PushModel.getList({ repo: project.name, revision })
return PushModel.getList({ repo: project.name, commit_revision: revision })
.then(async (resp) => {
const { results } = await resp.json();
const resultSet = results[0];
Expand Down Expand Up @@ -634,7 +634,7 @@ perf.controller('CompareSubtestDistributionCtrl', ['$scope', '$stateParams', '$q
const fetchAndDrawReplicateGraph = function (project, revision, subtestSignature, target) {
const replicateData = {};

return PushModel.getList({ repo: project, revision })
return PushModel.getList({ repo: project, commit_revision: revision })
.then(async (resp) => {
const { results } = await resp.json();
replicateData.resultSet = results[0];
Expand Down
2 changes: 1 addition & 1 deletion ui/perfherder/SelectorCard.jsx
Expand Up @@ -159,7 +159,7 @@ export default class SelectorCard extends React.Component {
const url = `${getProjectUrl(
pushEndpoint,
selectedRepo,
)}${createQueryParams({ revision: value })}`;
)}${createQueryParams({ commit_revision: value })}`;

const { data: revisions, failureStatus } = await getData(url);

Expand Down

0 comments on commit b224460

Please sign in to comment.