[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/remove-branch-commitsForDays into lp:launchpad

2016-10-16 Thread noreply
The proposal to merge lp:~cjwatson/launchpad/remove-branch-commitsForDays into 
lp:launchpad has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/remove-branch-commitsForDays/+merge/308572
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/remove-branch-commitsForDays into lp:launchpad

2016-10-15 Thread William Grant
Review: Approve code


-- 
https://code.launchpad.net/~cjwatson/launchpad/remove-branch-commitsForDays/+merge/308572
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/remove-branch-commitsForDays into lp:launchpad

2016-10-14 Thread Colin Watson
Colin Watson has proposed merging 
lp:~cjwatson/launchpad/remove-branch-commitsForDays into lp:launchpad.

Commit message:
Remove unused Branch.commitsForDays.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/remove-branch-commitsForDays/+merge/308572
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/remove-branch-commitsForDays into lp:launchpad.
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py	2016-10-14 15:07:08 +
+++ lib/lp/code/interfaces/branch.py	2016-10-15 02:40:17 +
@@ -1002,15 +1002,6 @@
 detail page.
 """
 
-def commitsForDays(since):
-"""Get a list of commit counts for days since `since`.
-
-This method returns all commits for the branch, so this includes
-revisions brought in through merges.
-
-:return: A list of tuples like (date, count).
-"""
-
 def checkUpgrade():
 """Check whether an upgrade should be performed, and raise if not.
 

=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py	2016-10-12 23:22:33 +
+++ lib/lp/code/model/branch.py	2016-10-15 02:40:17 +
@@ -25,10 +25,8 @@
 from storm.expr import (
 And,
 Coalesce,
-Count,
 Desc,
 Join,
-NamedFunc,
 Not,
 Or,
 Select,
@@ -1367,21 +1365,6 @@
 job = getUtility(IReclaimBranchSpaceJobSource).create(branch_id)
 job.celeryRunOnCommit()
 
-def commitsForDays(self, since):
-"""See `IBranch`."""
-
-class DateTrunc(NamedFunc):
-name = "date_trunc"
-
-results = Store.of(self).find(
-(DateTrunc(u'day', Revision.revision_date), Count(Revision.id)),
-Revision.id == BranchRevision.revision_id,
-Revision.revision_date > since,
-BranchRevision.branch == self)
-results = results.group_by(
-DateTrunc(u'day', Revision.revision_date))
-return sorted(results)
-
 def checkUpgrade(self):
 if self.branch_type is not BranchType.HOSTED:
 raise CannotUpgradeNonHosted(self)

=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py	2016-10-12 23:22:33 +
+++ lib/lp/code/model/tests/test_branch.py	2016-10-15 02:40:17 +
@@ -152,7 +152,6 @@
 run_with_login,
 TestCase,
 TestCaseWithFactory,
-time_counter,
 WebServiceTestCase,
 )
 from lp.testing.factory import LaunchpadObjectFactory
@@ -2700,73 +2699,6 @@
 BranchLifecycleStatus.EXPERIMENTAL, branch.lifecycle_status)
 
 
-class TestBranchCommitsForDays(TestCaseWithFactory):
-"""Tests for `Branch.commitsForDays`."""
-
-layer = DatabaseFunctionalLayer
-
-def setUp(self):
-TestCaseWithFactory.setUp(self)
-# Use a 30 day epoch for the tests.
-self.epoch = datetime.now(tz=UTC) - timedelta(days=30)
-
-def date_generator(self, epoch_offset, delta=None):
-if delta is None:
-delta = timedelta(days=1)
-return time_counter(self.epoch + timedelta(days=epoch_offset), delta)
-
-def test_empty_branch(self):
-# A branch with no commits returns an empty list.
-branch = self.factory.makeAnyBranch()
-self.assertEqual([], branch.commitsForDays(self.epoch))
-
-def test_commits_before_epoch_not_returned(self):
-# Commits that occur before the epoch are not returned.
-branch = self.factory.makeAnyBranch()
-self.factory.makeRevisionsForBranch(
-branch, date_generator=self.date_generator(-10))
-self.assertEqual([], branch.commitsForDays(self.epoch))
-
-def test_commits_after_epoch_are_returned(self):
-# Commits that occur after the epoch are returned.
-branch = self.factory.makeAnyBranch()
-self.factory.makeRevisionsForBranch(
-branch, count=5, date_generator=self.date_generator(1))
-# There is one commit for each day starting from epoch + 1.
-start = self.epoch + timedelta(days=1)
-# Clear off the fractional parts of the day.
-start = datetime(start.year, start.month, start.day)
-commits = []
-for count in range(5):
-commits.append((start + timedelta(days=count), 1))
-self.assertEqual(commits, branch.commitsForDays(self.epoch))
-
-def test_commits_are_grouped(self):
-# The commits are grouped to give counts of commits for the days.
-branch = self.factory.makeAnyBranch()
-start = self.epoch + timedelta(days=1)
-# Add 8 commits starting from 5pm (+ whatever minutes).
-# 5, 7, 9, 11pm, then 1, 3, 5, 7am for the following day.
-start = start.replace(hour=17)
-date_generator = time_counter(start, timedelta(hours=2))
-self.factory.makeRevisionsForBranch(
-