Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Remove duplicated branch test
Browse files Browse the repository at this point in the history
  • Loading branch information
jabley committed Aug 16, 2014
1 parent f50b701 commit f6870d3
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions backdrop/core/data_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,30 @@ def build_data(results, query):
return SimpleData(results)

if query.flatten:
results = flat_merge(query.group_keys, query.collect, results)
merge_fn = flat_merge
group_period_presenter = PeriodFlatData
group_presenter = FlatData
period_presenter = PeriodFlatData
else:
results = nested_merge(query.group_keys, query.collect, results)
merge_fn = nested_merge
group_period_presenter = PeriodGroupedData
group_presenter = GroupedData
period_presenter = PeriodData

results = merge_fn(query.group_keys, query.collect, results)
results = _sort_grouped_results(results, query.sort_by)
results = _limit_grouped_results(results, query.limit)

if query.group_by and query.period:
if query.flatten:
data = PeriodFlatData(results, period=query.period)
else:
data = PeriodGroupedData(results, period=query.period)
data = group_period_presenter(results, period=query.period)
if query.start_at and query.end_at:
data.fill_missing_periods(
query.start_at, query.end_at, collect=query.collect)
return data
elif query.group_by:
if query.flatten:
return FlatData(results)
else:
return GroupedData(results)
return group_presenter(results)
elif query.period:
if query.flatten:
data = PeriodFlatData(results, period=query.period)
else:
data = PeriodData(results, period=query.period)
data = period_presenter(results, period=query.period)
if query.start_at and query.end_at:
data.fill_missing_periods(
query.start_at, query.end_at, collect=query.collect)
Expand Down

1 comment on commit f6870d3

@nick-gravgaard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good :)

Please sign in to comment.