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
=== modified file 'charmworld/views/api.py'
--- charmworld/views/api.py 2013-06-18 15:11:00 +0000
+++ charmworld/views/api.py 2013-06-18 15:11:30 +0000
@@ -1,6 +1,9 @@
1__metaclass__ = type1__metaclass__ = type
22
3from datetime import datetime3from datetime import (
4 datetime,
5 timedelta,
6)
4from email.utils import parseaddr7from email.utils import parseaddr
5from inspect import getargspec8from inspect import getargspec
6import json9import json
@@ -217,6 +220,7 @@
217 now = datetime.utcnow()220 now = datetime.utcnow()
218 else:221 else:
219 now = _now222 now = _now
223 since = now - timedelta(30)
220 charm = Charm(charm_data)224 charm = Charm(charm_data)
221 result = {225 result = {
222 'id': cls._get_api_id(charm),226 'id': cls._get_api_id(charm),
@@ -224,7 +228,7 @@
224 'has_icon': 'icon.svg' in charm.files,228 'has_icon': 'icon.svg' in charm.files,
225 'categories': charm.categories,229 'categories': charm.categories,
226 'downloads_in_past_30_days': charm.downloads_in_past_30_days,230 'downloads_in_past_30_days': charm.downloads_in_past_30_days,
227 'commits_in_past_30_days': len(charm.changes_since(now)),231 'commits_in_past_30_days': len(charm.changes_since(since)),
228 'weight': weight,232 'weight': weight,
229 'is_approved': charm.promulgated,233 'is_approved': charm.promulgated,
230 }234 }
231235
=== modified file 'charmworld/views/tests/test_api.py'
--- charmworld/views/tests/test_api.py 2013-06-18 15:11:00 +0000
+++ charmworld/views/tests/test_api.py 2013-06-18 15:11:30 +0000
@@ -984,8 +984,9 @@
984 formatted = self.api_class._format_related(charm, 0, _now=now)984 formatted = self.api_class._format_related(charm, 0, _now=now)
985 self.assertEqual(27, formatted['commits_in_past_30_days'])985 self.assertEqual(27, formatted['commits_in_past_30_days'])
986 charm = factory.get_charm_json(986 charm = factory.get_charm_json(
987 changes=[factory.makeChange(created=now) for x in range(32)] +987 changes=[factory.makeChange(created=date(2013, 05, 18))
988 [factory.makeChange(created=date(2013, 04, 17))])988 for x in range(32)] +
989 [factory.makeChange(created=date(2013, 05, 17))])
989 formatted = self.api_class._format_related(990 formatted = self.api_class._format_related(
990 charm, 0, _now=now)991 charm, 0, _now=now)
991 self.assertEqual(32, formatted['commits_in_past_30_days'])992 self.assertEqual(32, formatted['commits_in_past_30_days'])

Subscribers

People subscribed via source and target branches