       obj.lastWeek.push report
   obj
 
+# Transforms a `sequelize magic` object into a plain good old JavaScript
+# object, with a formatted date.
+formatReports = (reports) ->
+  formattedReports = _.map reports, (r) -> 
+    formattedReport = {}
+    formattedReport.updatedAt = moment(r.updatedAt).format("MMM Do YYYY")
+    formattedReport.title = r.title
+    formattedReport.introduction = r.introduction
+    formattedReport
+  formattedReports
+    
 exports.index = (req, res) ->
   # TODO: this is a mess, we need a better way of handling this hell of 
   # nested callbacks!

    Indicator.findAll().success((indicators)->
      Report.findAll().success((reports) ->
        res.render "dashboard",
          reports: reports
          indicators: indicators
        ).error((error)->
            console.error error
            res.render(500, "Error fetching the reports")
          )
      )
    ).error((error) ->
    console.error error
    res.render(500, "Error seeding DB")
  )

_ = require('underscore')
moment = require('moment')

Report = require '../models/report'
Indicator = require('../models/indicator')
