From 13f3207719908ae86f0a41f94fbc5da4eb038b96 Mon Sep 17 00:00:00 2001 From: lixunhuan Date: Sat, 27 Dec 2014 02:18:54 +0800 Subject: [PATCH 1/2] fix summarize 500 and also add some guards. if len(timestamps) = len(series) - 1, then the code breaks and returns 500 to client. --- graphite_api/functions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/graphite_api/functions.py b/graphite_api/functions.py index 05fe920..e44d5c2 100644 --- a/graphite_api/functions.py +++ b/graphite_api/functions.py @@ -2909,11 +2909,13 @@ def summarize(requestContext, seriesList, intervalString, func='sum', for series in seriesList: buckets = {} - timestamps = range(int(series.start), int(series.end), + timestamps = range(int(series.start), int(series.end) + 1, int(series.step)) datapoints = zip_longest(timestamps, series) for timestamp, value in datapoints: + if timestamp is None: + continue if alignToFrom: bucketInterval = int((timestamp - series.start) / interval) else: From a2e1d62e9cd0a33301907d3c162c5ff3a945b9ac Mon Sep 17 00:00:00 2001 From: lixunhuan Date: Tue, 13 Jan 2015 12:01:07 +0800 Subject: [PATCH 2/2] allow header for descartes --- graphite_api/middleware.py | 1 + 1 file changed, 1 insertion(+) diff --git a/graphite_api/middleware.py b/graphite_api/middleware.py index eff7868..322bb24 100644 --- a/graphite_api/middleware.py +++ b/graphite_api/middleware.py @@ -18,6 +18,7 @@ def __call__(self, environ, start_response): if netloc in self.origins or '*' in self.origins: allow_origin = [ ('Access-Control-Allow-Origin', origin), + ('Access-Control-Allow-Headers', 'origin,authorization, accept'), ('Access-Control-Allow-Credentials', 'true'), ] if environ['REQUEST_METHOD'] == 'OPTIONS':