From ebc7c5a1ed9d3a16bb3d1f1726faa9f76c9add7f Mon Sep 17 00:00:00 2001 From: Lisa P Date: Tue, 13 Oct 2015 12:06:37 +0200 Subject: [PATCH] use different query more logic --- app/routes/branches.coffee | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/routes/branches.coffee b/app/routes/branches.coffee index 42d422b2..29114be6 100644 --- a/app/routes/branches.coffee +++ b/app/routes/branches.coffee @@ -14,15 +14,18 @@ Route = TravisRoute.extend if @get('auth.signedIn') options.headers = { Authorization: "token #{@auth.token()}" } - $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100", options).then (response) -> + $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100&sort_by=exists_on_github", options).then (response) -> allTheBranches = response.branches - unless response['@pagination'].is_last - $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100&offset=1", options).then (response) -> - allTheBranches = allTheBranches.concat(response.branches) - allTheBranches - else - allTheBranches + defaultBranch = allTheBranches.filter (item, index) -> + item if item.repository.default_branch['@href'] == item['@href'] + + allTheBranches + unless defaultBranch.length == 1 + $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100&offset=1&sort_by=exists_on_github", options).then (response) -> + allTheBranches = allTheBranches.concat(response.branches) + + allTheBranches activate: () -> $('.tab.tabs--main li').removeClass('active')