Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
cater for null group_by key in couch
Browse files Browse the repository at this point in the history
  • Loading branch information
snopoke committed Aug 20, 2013
1 parent 8b745a9 commit 0ad1083
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fluff/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def __init__(self, value):
elif isinstance(value, list):
self.value = dict(date=value[0], value=value[1], group_by=None)

if not isinstance(self.value['date'], datetime.date):
if self.value['date'] and not isinstance(self.value['date'], datetime.date):
self.value['date'] = datetime.datetime.strptime(self.value['date'], '%Y-%m-%d').date()

def __key(self):
Expand Down
5 changes: 3 additions & 2 deletions fluff/_design/views/generic/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ function (doc) {
for (i = 0; i < doc[calcName][emitterName].length; i++) {
var value = doc[calcName][emitterName][i];
if (typeOf(value) === 'object') {
var custom_key = value['group_by']
emit(custom_key.concat([calcName, emitterName, value['date']]), value['value']);
var custom_key = value['group_by'];
key = custom_key === null ? key : custom_key;

This comment has been minimized.

Copy link
@dannyroberts

dannyroberts Aug 27, 2013

Member

Pretty sure this isn't ok—it's overwriting the default key that's going to be used everywhere below it in the loop.

This comment has been minimized.

Copy link
@snopoke

snopoke Aug 28, 2013

Author Contributor

😬 #48

emit(key.concat([calcName, emitterName, value['date']]), value['value']);
} else {
emit(key.concat([calcName, emitterName, value[0]]), value[1]);
}
Expand Down

0 comments on commit 0ad1083

Please sign in to comment.