Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
chart starter
Browse files Browse the repository at this point in the history
  • Loading branch information
larryboymi committed Oct 23, 2016
1 parent 681101d commit a60a20f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions services/toChart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const mango = require('./mango')
const _ = require('underscore')

const clientMango = () => ({
selector: {
_id: {
$gt: null
}
},
limit: 600
})

const metadata = ['_id', '_rev', 'coc', 'name', 'year']

const getClients = (req, res) =>
mango('coc_estimates_in_time', clientMango())
.then((data) => {
const labels = _(Object.keys(data[0])).difference(metadata)
const series = data.map((coc_time) => labels.map((label) => coc_time[label]))
res.send({labels, series})
})

module.exports = getClients

0 comments on commit a60a20f

Please sign in to comment.