'Extract the Data'

def _extract(self, days, r, **attr):

    resource = r.resource
    resource.add_filter(((FS('date') > days[0].replace(hour=0, minute=0, second=0, microsecond=0)) & (FS('date') < days[(-1)].replace(hour=23, minute=59, second=59))))
    fields = ['body', 'date', 'location_id', 'post_module.module', 'post_module.resource', 'post_module.record']
    data = resource.select(fields, represent=True, raw_data=True)
    cols = []
    cappend = cols.append
    max_rows = []
    mappend = max_rows.append
    for day in days:
        cappend([])
        mappend(0)
    len_days = len(days)
    for record in data.rows:
        date = record._row['cms_post.date']
        for i in range(len_days):
            if (date < days[(i + 1)]):
                cols[i].append(record)
                max_rows[i] += 1
                break
    rows = []
    rappend = rows.append
    len_rows = max(max_rows)
    for i in range(len_rows):
        rappend([])
    for row in rows:
        rappend = row.append
        for col in cols:
            if len(col):
                rappend(col.pop())
            else:
                rappend(Storage())
    return rows
