Skip to content

Commit

Permalink
Guard against 'view' that is set to None
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Feb 2, 2018
1 parent b8f3261 commit 70a1275
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cr/cube/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ def __init__(self, dim, selections=None):

@property
def subtotals(self):
insertions_data = self._dim.get('references', {}) \
.get('view', {}) \
.get('transform', {}) \
.get('insertions', [])
view = self._dim.get('references', {}).get('view', {})

if not view:
# View can be both None and {}, thus the edge case.
return []

insertions_data = view.get('transform', {}).get('insertions', [])
subtotals = [Subtotal(data) for data in insertions_data]
return [subtotal for subtotal in subtotals if subtotal.is_valid]

Expand Down

0 comments on commit 70a1275

Please sign in to comment.