launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22024
[Merge] lp:~cjwatson/launchpad/use-more-statistics into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/use-more-statistics into lp:launchpad.
Commit message:
Use statistics for public specifications, branches, and Git repositories on the front page.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/use-more-statistics/+merge/333933
This will save a little over half a second.
We should check that the statistics are present on all instances first; qastaging and dogfood may need some manual work.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/use-more-statistics into lp:launchpad.
=== modified file 'database/sampledata/current-dev.sql'
--- database/sampledata/current-dev.sql 2016-10-05 09:32:57 +0000
+++ database/sampledata/current-dev.sql 2017-11-18 13:33:27 +0000
@@ -1,4 +1,4 @@
--- Copyright 2010-2016 Canonical Ltd. This software is licensed under the
+-- Copyright 2010-2017 Canonical Ltd. This software is licensed under the
-- GNU Affero General Public License version 3 (see the file LICENSE).
-- Created using pg_dump (PostgreSQL) 9.3.5
@@ -4625,6 +4625,9 @@
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (24, 'products_with_bugs', 5, '2007-04-29 23:45:04.416248');
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (25, 'products_with_questions', 1, '2007-04-29 23:45:04.416248');
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (26, 'reviewed_products', 1, '2007-04-29 23:45:04.416248');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (27, 'public_specification_count', 12, '2017-11-18 13:15:56.602272');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (28, 'public_branch_count', 30, '2017-11-18 13:16:47.719834');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (29, 'public_git_repository_count', 0, '2017-11-18 13:17:08.109074');
ALTER TABLE launchpadstatistic ENABLE TRIGGER ALL;
=== modified file 'database/sampledata/current.sql'
--- database/sampledata/current.sql 2016-10-05 09:32:57 +0000
+++ database/sampledata/current.sql 2017-11-18 13:33:27 +0000
@@ -1,4 +1,4 @@
--- Copyright 2010-2016 Canonical Ltd. This software is licensed under the
+-- Copyright 2010-2017 Canonical Ltd. This software is licensed under the
-- GNU Affero General Public License version 3 (see the file LICENSE).
-- Created using pg_dump (PostgreSQL) 9.3.5
@@ -4537,6 +4537,9 @@
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (24, 'products_with_bugs', 5, '2007-04-29 23:45:04.416248');
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (25, 'products_with_questions', 1, '2007-04-29 23:45:04.416248');
INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (26, 'reviewed_products', 1, '2007-04-29 23:45:04.416248');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (27, 'public_specification_count', 12, '2017-11-18 13:15:56.602272');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (28, 'public_branch_count', 30, '2017-11-18 13:16:47.719834');
+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (29, 'public_git_repository_count', 0, '2017-11-18 13:17:08.109074');
ALTER TABLE launchpadstatistic ENABLE TRIGGER ALL;
=== modified file 'lib/lp/app/browser/root.py'
--- lib/lp/app/browser/root.py 2017-04-13 22:29:09 +0000
+++ lib/lp/app/browser/root.py 2017-11-18 13:33:27 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Browser code for the Launchpad root page."""
@@ -32,10 +32,7 @@
from lp.app.errors import NotFoundError
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.app.validators.name import sanitize_name
-from lp.blueprints.interfaces.specification import ISpecificationSet
from lp.bugs.interfaces.bug import IBugSet
-from lp.code.interfaces.branchcollection import IAllBranches
-from lp.code.interfaces.gitcollection import IAllGitRepositories
from lp.registry.browser.announcement import HasAnnouncementsView
from lp.registry.interfaces.person import IPersonSet
from lp.registry.interfaces.pillar import IPillarNameSet
@@ -113,12 +110,13 @@
@property
def branch_count(self):
"""The total branch count of public branches in all of Launchpad."""
- return getUtility(IAllBranches).visibleByUser(None).count()
+ return getUtility(ILaunchpadStatisticSet).value('public_branch_count')
@property
def gitrepository_count(self):
"""The total Git repository count in all of Launchpad."""
- return getUtility(IAllGitRepositories).visibleByUser(None).count()
+ return getUtility(ILaunchpadStatisticSet).value(
+ 'public_git_repository_count')
@property
def bug_count(self):
@@ -138,7 +136,8 @@
@property
def blueprint_count(self):
"""The total blueprint count in all of Launchpad."""
- return getUtility(ISpecificationSet).specificationCount(None)
+ return getUtility(ILaunchpadStatisticSet).value(
+ 'public_specification_count')
@property
def answer_count(self):
Follow ups