function groupByDay(dataTable, crimeType) {
let groupData, date, location, arrested, info, results = {};
const dataFilter = arrow.predicate.custom(i => {
const date = toDate(dataTable.getColumn('Date').get(i));
const primaryType = dataTable.getColumn('PrimaryType').get(i);
return ((crimeType === '' || primaryType === crimeType) &&
date.getMonth() <= 8);
}, b => 1);
dataTable.filter(dataFilter)
.scan((index) => {
const day = toDate(date(index)).toISOString().substring(0, 10);
if (!results[day]) {
results[day] = [];
}
const dataRecord = {};
dataRecord['date'] = toDate(date(index));
dataRecord['location'] = location(index);
dataRecord['arrested'] = arrested(index);
dataRecord['info'] = info(index);
results[day].push(dataRecord);
}, (batch) => {
date = arrow.predicate.col('Date').bind(batch);
location = arrow.predicate.col('LocationDescription').bind(batch);
arrested = arrow.predicate.col('Arrest').bind(batch);
info = arrow.predicate.col('Description').bind(batch);
});
return results;
}