From aa769f026a98c344f1f33c122772f972ee0f2531 Mon Sep 17 00:00:00 2001 From: Blake Williams Date: Sun, 4 Jan 2015 19:49:29 -0500 Subject: [PATCH] Use computed property for versions length A bug is causing `versions` to be fetched once for each version causing excessive queries to slow down or freeze the page. * Turn versions.length into a computed property to prevent extra requests --- app/controllers/crate/index.js | 4 ++++ app/templates/crate/index.hbs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/crate/index.js b/app/controllers/crate/index.js index 4ac2272875a..bbad81c2f86 100644 --- a/app/controllers/crate/index.js +++ b/app/controllers/crate/index.js @@ -36,6 +36,10 @@ export default Ember.ObjectController.extend({ this.get('repository'); }.property('homepage', 'wiki', 'mailing_list', 'documentation', 'repository'), + versionsCount: function() { + return this.get('versions.length'); + }.property('versions.@each'), + displayedAuthors: function() { var self = this; if (!this.get('currentVersion')) { diff --git a/app/templates/crate/index.hbs b/app/templates/crate/index.hbs index c53659ff98d..1848cc4fc62 100644 --- a/app/templates/crate/index.hbs +++ b/app/templates/crate/index.hbs @@ -200,7 +200,7 @@
- {{ versions.length }} + {{ versionsCount }} Versions published