Skip to content

Instantly share code, notes, and snippets.

@hansonkd
Last active January 17, 2017 15:29
Show Gist options
  • Save hansonkd/d076ccb72c7cdee6dc47dfaf2912db83 to your computer and use it in GitHub Desktop.
Save hansonkd/d076ccb72c7cdee6dc47dfaf2912db83 to your computer and use it in GitHub Desktop.
all_securities = Security.objects.filter(company=company).for_report().iterator()
def flatten(*args):
def transform_pipeline(mdl):
data = FlatData()
for fn in args:
fn(data, mdl)
return data
return transform_pipeline
def add_issue_date(flat, mdl):
flat.issue_date = mdl.get_issue_date()
def add_label(flat, mdl):
flat.label = mdl.get_label()
flat_securities = (
conduit(all_securities)
...
.map(
flatten(
add_issue_date,
add_label
)
)
...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment