|
a/Allura/allura/lib/zarkov_helpers.py |
|
b/Allura/allura/lib/zarkov_helpers.py |
|
... |
|
... |
16 |
|
16 |
|
17 |
def event(self, type, context, extra=None):
|
17 |
def event(self, type, context, extra=None):
|
18 |
obj = dict(
|
18 |
obj = dict(
|
19 |
type=type, context=context, extra=extra)
|
19 |
type=type, context=context, extra=extra)
|
20 |
self._sock.send(bson.BSON.encode(obj))
|
20 |
self._sock.send(bson.BSON.encode(obj))
|
21 |
|
|
|
22 |
def event_noval(self, type, context, extra=None):
|
|
|
23 |
from zarkov import model
|
|
|
24 |
obj = model.event.make(dict(
|
|
|
25 |
type=type,
|
|
|
26 |
context=context,
|
|
|
27 |
extra=extra))
|
|
|
28 |
obj['$command'] = 'event_noval'
|
|
|
29 |
self._sock.send(bson.BSON.encode(obj))
|
|
|
30 |
|
|
|
31 |
def _command(self, cmd, **kw):
|
|
|
32 |
d = dict(kw)
|
|
|
33 |
d['$command'] = cmd
|
|
|
34 |
self._sock.send(bson.BSON.encode(d))
|
|
|
35 |
|
21 |
|
36 |
def zero_fill_zarkov_result(zarkov_data, period, start_date, end_date):
|
22 |
def zero_fill_zarkov_result(zarkov_data, period, start_date, end_date):
|
37 |
"""Return a new copy of zarkov_data (a dict returned from a zarkov
|
23 |
"""Return a new copy of zarkov_data (a dict returned from a zarkov
|
38 |
query) with the timeseries data zero-filled for missing dates.
|
24 |
query) with the timeseries data zero-filled for missing dates.
|
39 |
|
25 |
|
|
... |
|
... |
66 |
|
52 |
|
67 |
Args:
|
53 |
Args:
|
68 |
time_series (list): A list of [timestamp, value] pairs, e.g.:
|
54 |
time_series (list): A list of [timestamp, value] pairs, e.g.:
|
69 |
[[1306886400000.0, 1], [1309478400000.0, 0]]
|
55 |
[[1306886400000.0, 1], [1309478400000.0, 0]]
|
70 |
period (str): 'month' or 'date' for monthly or daily timestamps
|
56 |
period (str): 'month' or 'date' for monthly or daily timestamps
|
71 |
start_date (datetime or str): Start of the date range. If a str is
|
57 |
start_date (datetime): Start of the date range.
|
72 |
passed, it must be in %Y-%m-%d format.
|
|
|
73 |
end_date (datetime or str): End of the date range. If a str is
|
58 |
end_date (datetime or str): End of the date range.
|
74 |
passed, it must be in %Y-%m-%d format.
|
|
|
75 |
|
59 |
|
76 |
Returns:
|
60 |
Returns:
|
77 |
list. A new copy of time_series, zero-filled.
|
61 |
list. A new copy of time_series, zero-filled.
|
78 |
|
62 |
|
79 |
If you want to zero-fill an entire zarkov result, you should use
|
63 |
If you want to zero-fill an entire zarkov result, you should use
|