codeforamerica/survey-api — pull request #6 by hampelm (2012-06-27 02:43:01+00:00)
Title: Implements filters for exports 

WSU needs to export data to CSV in a particular format. To implement this, I pulled CSV export code into the exportSurveyAsCSV function. That function takes as its last parameter a list of limiting functions. These filtering functions expect a reference to an array of results (as delivered by cursor.toArray). The limiting functions manipulate the array as needed (eg, one keeps only the most recent result for each parcel). All implemented in a fairly naive way; not expecting this will be a major bottleneck going forward.

Also included are tests of the limiting functions using mocha. Instructions for running the tests are in the readme; the short is that you run "make test".