DashboardController.js

28 lines | 746 B Blame History Raw Download
'use strict'
const Theme = use('App/Models/Theme')
const Element = use('App/Models/Element')
const Submission = use('App/Models/Submission')
const Steward = use('App/Models/Steward')

class DashboardController {
  async index({view}) {
    const numThemes = await Theme.getCount()
    const numElements = await Element.getCount()
    const submissions = await Submission.query()
      .with('status')
      .fetch()
    const stewards = await Steward.query()
      .with('contact.organization.type')
      .fetch()

    return view.render('dashboard.index', {
      numThemes: numThemes,
      numElements: numElements,
      submissions: submissions.toJSON(),
      stewards: stewards.toJSON()
    })
  }
}

module.exports = DashboardController