Merge lp:~cjwatson/launchpad/use-more-statistics into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18509
Proposed branch: lp:~cjwatson/launchpad/use-more-statistics
Merge into: lp:launchpad
Diff against target: 86 lines (+14/-9)
3 files modified
database/sampledata/current-dev.sql (+4/-1)
database/sampledata/current.sql (+4/-1)
lib/lp/app/browser/root.py (+6/-7)
To merge this branch: bzr merge lp:~cjwatson/launchpad/use-more-statistics
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+333933@code.launchpad.net

Commit message

Use statistics for public specifications, branches, and Git repositories on the front page.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/sampledata/current-dev.sql'
2--- database/sampledata/current-dev.sql 2016-10-05 09:32:57 +0000
3+++ database/sampledata/current-dev.sql 2017-11-18 13:33:27 +0000
4@@ -1,4 +1,4 @@
5--- Copyright 2010-2016 Canonical Ltd. This software is licensed under the
6+-- Copyright 2010-2017 Canonical Ltd. This software is licensed under the
7 -- GNU Affero General Public License version 3 (see the file LICENSE).
8 -- Created using pg_dump (PostgreSQL) 9.3.5
9
10@@ -4625,6 +4625,9 @@
11 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (24, 'products_with_bugs', 5, '2007-04-29 23:45:04.416248');
12 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (25, 'products_with_questions', 1, '2007-04-29 23:45:04.416248');
13 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (26, 'reviewed_products', 1, '2007-04-29 23:45:04.416248');
14+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (27, 'public_specification_count', 12, '2017-11-18 13:15:56.602272');
15+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (28, 'public_branch_count', 30, '2017-11-18 13:16:47.719834');
16+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (29, 'public_git_repository_count', 0, '2017-11-18 13:17:08.109074');
17
18
19 ALTER TABLE launchpadstatistic ENABLE TRIGGER ALL;
20
21=== modified file 'database/sampledata/current.sql'
22--- database/sampledata/current.sql 2016-10-05 09:32:57 +0000
23+++ database/sampledata/current.sql 2017-11-18 13:33:27 +0000
24@@ -1,4 +1,4 @@
25--- Copyright 2010-2016 Canonical Ltd. This software is licensed under the
26+-- Copyright 2010-2017 Canonical Ltd. This software is licensed under the
27 -- GNU Affero General Public License version 3 (see the file LICENSE).
28 -- Created using pg_dump (PostgreSQL) 9.3.5
29
30@@ -4537,6 +4537,9 @@
31 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (24, 'products_with_bugs', 5, '2007-04-29 23:45:04.416248');
32 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (25, 'products_with_questions', 1, '2007-04-29 23:45:04.416248');
33 INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (26, 'reviewed_products', 1, '2007-04-29 23:45:04.416248');
34+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (27, 'public_specification_count', 12, '2017-11-18 13:15:56.602272');
35+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (28, 'public_branch_count', 30, '2017-11-18 13:16:47.719834');
36+INSERT INTO launchpadstatistic (id, name, value, dateupdated) VALUES (29, 'public_git_repository_count', 0, '2017-11-18 13:17:08.109074');
37
38
39 ALTER TABLE launchpadstatistic ENABLE TRIGGER ALL;
40
41=== modified file 'lib/lp/app/browser/root.py'
42--- lib/lp/app/browser/root.py 2017-04-13 22:29:09 +0000
43+++ lib/lp/app/browser/root.py 2017-11-18 13:33:27 +0000
44@@ -1,4 +1,4 @@
45-# Copyright 2009-2016 Canonical Ltd. This software is licensed under the
46+# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
47 # GNU Affero General Public License version 3 (see the file LICENSE).
48 """Browser code for the Launchpad root page."""
49
50@@ -32,10 +32,7 @@
51 from lp.app.errors import NotFoundError
52 from lp.app.interfaces.launchpad import ILaunchpadCelebrities
53 from lp.app.validators.name import sanitize_name
54-from lp.blueprints.interfaces.specification import ISpecificationSet
55 from lp.bugs.interfaces.bug import IBugSet
56-from lp.code.interfaces.branchcollection import IAllBranches
57-from lp.code.interfaces.gitcollection import IAllGitRepositories
58 from lp.registry.browser.announcement import HasAnnouncementsView
59 from lp.registry.interfaces.person import IPersonSet
60 from lp.registry.interfaces.pillar import IPillarNameSet
61@@ -113,12 +110,13 @@
62 @property
63 def branch_count(self):
64 """The total branch count of public branches in all of Launchpad."""
65- return getUtility(IAllBranches).visibleByUser(None).count()
66+ return getUtility(ILaunchpadStatisticSet).value('public_branch_count')
67
68 @property
69 def gitrepository_count(self):
70 """The total Git repository count in all of Launchpad."""
71- return getUtility(IAllGitRepositories).visibleByUser(None).count()
72+ return getUtility(ILaunchpadStatisticSet).value(
73+ 'public_git_repository_count')
74
75 @property
76 def bug_count(self):
77@@ -138,7 +136,8 @@
78 @property
79 def blueprint_count(self):
80 """The total blueprint count in all of Launchpad."""
81- return getUtility(ISpecificationSet).specificationCount(None)
82+ return getUtility(ILaunchpadStatisticSet).value(
83+ 'public_specification_count')
84
85 @property
86 def answer_count(self):