From 648d7579e40869642f48f9630ab43709bdb6eaac Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 10 Jun 2015 11:32:06 +0200 Subject: [PATCH] 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