Merge lp:~bac/charmworld/add-stats-to-api into lp:charmworld
Proposed by
Brad Crittenden
Status: | Merged |
---|---|
Approved by: | Brad Crittenden |
Approved revision: | 469 |
Merged at revision: | 467 |
Proposed branch: | lp:~bac/charmworld/add-stats-to-api |
Merge into: | lp:charmworld |
Diff against target: |
195 lines (+56/-31) 5 files modified
charmworld/views/api/__init__.py (+10/-1) charmworld/views/bundles.py (+3/-21) charmworld/views/tests/test_api.py (+16/-8) charmworld/views/tests/test_bundles.py (+3/-1) charmworld/views/utils.py (+24/-0) |
To merge this branch: | bzr merge lp:~bac/charmworld/add-stats-to-api |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Gui Bot | continuous-integration | Approve | |
Charmworld Developers | Pending | ||
Review via email: mp+195991@code.launchpad.net |
Commit message
Description of the change
Add download stats to bundle API call.
To post a comment you must log in.
Reviewers: mp+195991_ code.launchpad. net,
Message:
Please take a look.
Description:
Add download stats to bundle API call.
https:/ /code.launchpad .net/~bac/ charmworld/ add-stats- to-api/ +merge/ 195991
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/29850043/
Affected files (+58, -31 lines): views/api/ __init_ _.py views/bundles. py views/tests/ test_api. py views/tests/ test_bundles. py views/utils. py
A [revision details]
M charmworld/
M charmworld/
M charmworld/
M charmworld/
M charmworld/
Index: [revision details] 20131119203355- yu8j8hqzmyv8f9d 1
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-
+New revision: <email address hidden>
Index: charmworld/ views/bundles. py views/bundles. py' views/bundles. py 2013-11-13 17:40:11 +0000 views/bundles. py 2013-11-20 18:08:03 +0000 views.utils import get_bundle_ downloads views.api import json_response views.helpers import ( README_ EXTS = ('', '.txt', '.md', '.markdown', '.mkd', '.rst')
=== modified file 'charmworld/
--- charmworld/
+++ charmworld/
@@ -8,12 +8,8 @@
from charmworld import cached_view_config
from charmworld.models import (
Bundle,
- DatedMetricSource,
-)
-from charmworld.utils import (
- build_metric_key,
- utc_today,
-)
+)
+from charmworld.
from charmworld.
from charmworld.
find_bundle,
@@ -29,17 +25,6 @@
SUPPORTED_
-class Statistics: get_range_ total(7, day) get_range_ total(30, day) get_range_ total(365 / 2, day) Bundle) :
- """A template helper that wraps a DatedMetric instance."""
-
- def __init__(self, metric, day=None):
- day = day or utc_today()
- self.past_7_days = metric.
- self.past_30_days = metric.
- self.past_half_year = metric.
- self.total = metric.get_total()
-
-
class BundleDetail(
service_keys = (
@@ -113,11 +98,8 @@
def _bundle_ view(request, bundle): ce.from_ db(request. db) key('deployment s', bundle.id) retrieve( metric_ key, create=True) downloads( request. db, bundle.id) dict(bundle) )
(request. user.nickname == bundle.owner))
- source = DatedMetricSour
- metric_key = build_metric_
- metric = source.
+ downloads = get_bundle_
bundle = BundleDetail(
- downloads = Statistics(metric)
try:
is_owner = bool((request.user is not None) and
Index: charmworld/ views/utils. py views/utils. py' views/utils. py 2013-10-20 19:09:02 +0000 views/utils. py 2013-11-20 17:16:29 +0000
=== modified file 'charmworld/
--- charmworld/
+++ charmworld/
@@ -1,5 +1,10 @@
import json
from webob import Response
+from charmworld.models import DatedMetricSource
+from charmworld.utils import (
+ build_metric_key,
+ utc_today,
+)
def json_response( status, value, headers=[]):
@@ -31,3 +36,22 @@
('Access- Control- Allow-Headers' , 'X-Requested- With'),
] + headers,
status_ code=status)
+
+
+class Statistics:
+ """A template helper that wraps a DatedMetric instance."""
+
+ def __init__(self, me...