Merge lp:~abentley/charmworld/fix-commits-in-past-30-days into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Aaron Bentley
Approved revision: 272
Merged at revision: 273
Proposed branch: lp:~abentley/charmworld/fix-commits-in-past-30-days
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 47 lines (+9/-4)
2 files modified
charmworld/views/api.py (+6/-2)
charmworld/views/tests/test_api.py (+3/-2)
To merge this branch: bzr merge lp:~abentley/charmworld/fix-commits-in-past-30-days
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+170108@code.launchpad.net

Commit message

Fix commits_in_past_30_days.

Description of the change

This branch fixes the commits_in_past_30_days in the "related" API endpoint.

It had been providing the number of commits since now, which is always empty, of course. Now it subtracts 30 days, as promised.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)
Revision history for this message
Charmworld Lander (charmworld-lander) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/charmworld-merger-trunk/335/console reported an error when processing this lp:~abentley/charmworld/fix-commits-in-past-30-days branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/views/api.py'
2--- charmworld/views/api.py 2013-06-18 15:11:00 +0000
3+++ charmworld/views/api.py 2013-06-18 15:11:30 +0000
4@@ -1,6 +1,9 @@
5 __metaclass__ = type
6
7-from datetime import datetime
8+from datetime import (
9+ datetime,
10+ timedelta,
11+)
12 from email.utils import parseaddr
13 from inspect import getargspec
14 import json
15@@ -217,6 +220,7 @@
16 now = datetime.utcnow()
17 else:
18 now = _now
19+ since = now - timedelta(30)
20 charm = Charm(charm_data)
21 result = {
22 'id': cls._get_api_id(charm),
23@@ -224,7 +228,7 @@
24 'has_icon': 'icon.svg' in charm.files,
25 'categories': charm.categories,
26 'downloads_in_past_30_days': charm.downloads_in_past_30_days,
27- 'commits_in_past_30_days': len(charm.changes_since(now)),
28+ 'commits_in_past_30_days': len(charm.changes_since(since)),
29 'weight': weight,
30 'is_approved': charm.promulgated,
31 }
32
33=== modified file 'charmworld/views/tests/test_api.py'
34--- charmworld/views/tests/test_api.py 2013-06-18 15:11:00 +0000
35+++ charmworld/views/tests/test_api.py 2013-06-18 15:11:30 +0000
36@@ -984,8 +984,9 @@
37 formatted = self.api_class._format_related(charm, 0, _now=now)
38 self.assertEqual(27, formatted['commits_in_past_30_days'])
39 charm = factory.get_charm_json(
40- changes=[factory.makeChange(created=now) for x in range(32)] +
41- [factory.makeChange(created=date(2013, 04, 17))])
42+ changes=[factory.makeChange(created=date(2013, 05, 18))
43+ for x in range(32)] +
44+ [factory.makeChange(created=date(2013, 05, 17))])
45 formatted = self.api_class._format_related(
46 charm, 0, _now=now)
47 self.assertEqual(32, formatted['commits_in_past_30_days'])

Subscribers

People subscribed via source and target branches