From 648d7579e40869642f48f9630ab43709bdb6eaac Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 10 Jun 2015 11:32:06 +0200 Subject: [PATCH 1/2] Use less expensive endpoints for getting repos with last builds We display a few recently built repos on landing page. Till now it was using quite expensive endpoint "/repos". This commit changes it to get last builds from builds endpoint and then fetch repositories by ids. --- app/routes/home.coffee | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/routes/home.coffee b/app/routes/home.coffee index 56d7f374..68a4c7bd 100644 --- a/app/routes/home.coffee +++ b/app/routes/home.coffee @@ -28,8 +28,10 @@ Route = BasicRoute.extend setTimeout => unless repos.get('length') - @store.find('repo').then (reposFromRequest) -> - repos.get('external').pushObjects reposFromRequest.toArray().slice(0, 3) + @store.find('build').then (builds) => + repoIds = builds.mapBy('data.repo').uniq().slice(0, 3) + @store.find('repo', ids: repoIds).then (reposFromRequest) -> + repos.get('external').pushObjects reposFromRequest.toArray() , 10000 @_super.apply this, arguments From 5f37bcb31266b323a694c13032cc054d30d9819d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 10 Jun 2015 12:19:13 +0200 Subject: [PATCH 2/2] Query for repos on landing page right away --- app/routes/home.coffee | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/routes/home.coffee b/app/routes/home.coffee index 68a4c7bd..6b341e51 100644 --- a/app/routes/home.coffee +++ b/app/routes/home.coffee @@ -26,13 +26,10 @@ Route = BasicRoute.extend @set('letMoreReposThrough', true) , 5000 - setTimeout => - unless repos.get('length') - @store.find('build').then (builds) => - repoIds = builds.mapBy('data.repo').uniq().slice(0, 3) - @store.find('repo', ids: repoIds).then (reposFromRequest) -> - repos.get('external').pushObjects reposFromRequest.toArray() - , 10000 + @store.find('build').then (builds) => + repoIds = builds.mapBy('data.repo').uniq().slice(0, 3) + @store.find('repo', ids: repoIds).then (reposFromRequest) -> + repos.get('external').pushObjects reposFromRequest.toArray() @_super.apply this, arguments