Permalink
Browse files

Better expressions integration, Updated README

  • Loading branch information...
1 parent 8ad7453 commit 49364f58089c4e822e8aac3a230b05981331939a @tsileo committed Oct 1, 2013
Showing with 16 additions and 4 deletions.
  1. +15 −3 README.rst
  2. +1 −1 cube/__init__.py
View
@@ -80,19 +80,31 @@ Usage
# or
cube.put("myevent", {'temp': 30}, time=datetime.now().isoformat())
+ # Low level queries
+ # =================
+
# Request events data
# See Cube queries:
# https://github.com/square/cube/wiki/Queries#wiki-metric
cube.event('myevent(temp)')
# Request metrics
- cube.metric(c.metric('sum(myevent)', step='36e5', start='2013-9-01'))
+ cube.metric('sum(myevent(temp))', step='36e5', start='2013-9-01'))
# or
- cube.metric(c.metric('sum(myevent)', step=ONE_HOUR, start='2013-9-01'))
+ cube.metric('sum(myevent(temp))', step=ONE_HOUR, start='2013-9-01'))
# Request known event types
cube.types()
+ # High level queries
+ # ==================
+
+ from cube.expressions import EventExpression, Sum
+ temp = EventExpression('myevent', 'temp')
+
+ cube.metric(Sum(temp), step=ONE_HOUR, start='2013-10-1')
+
+
Metric resolutions shortcut
---------------------------
@@ -140,7 +152,7 @@ Changelog
- Compatible with requests 2.0
- Added metric resolution shortcut
- Added a ``Event`` helper
-- Merged some parts of `sbuss/pypercube <https://github.com/sbuss/pypercube>`_, ``EventExpression`` and ``Filter``.
+- **Merged some parts of `sbuss/pypercube <https://github.com/sbuss/pypercube>`_**, ``time_utils``, ``EventExpression`` and ``Filter``.
View
@@ -66,7 +66,7 @@ def put(self, event_type, event_data={}, **kwargs):
return [event]
def make_query(self, query_type, expression, **kwargs):
- data = dict(expression=expression,
+ data = dict(expression=str(expression),
stop=kwargs.get('stop', datetime.utcnow().isoformat()))
data.update(kwargs)
r = requests.get(self.evaluator_url + query_type, params=data)

0 comments on commit 49364f5

Please sign in to comment.