Last active
July 1, 2016 13:33
-
-
Save aaronmcadam/97bb74bfd68ca6a56b82ce3ccdd320d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import fetchAttributes from '../services/attributes'; | |
/* eslint new-cap: "off" */ | |
const router = express.Router(); | |
router.route('/tasks/:taskId/attributes') | |
.get((req, res) => { | |
fetchAttributes(req.params.taskId).then(responses => res.json(responses)); | |
}); | |
export default router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import R from 'ramda'; | |
import callBizApi from './callBizApi'; | |
import extractAttributes from '../util/extractAttributes'; | |
import sumAttributes from '../util/sumAttributes'; | |
import averageAttributes from '../util/averageAttributes'; | |
const fetchAttributes = taskId => ( | |
new Promise(resolve => ( | |
callBizApi([`/tasks/${taskId}/responses`, `/tasks/${taskId}/questions`]) | |
.then(mapAttributes) | |
.then(resolve) | |
)) | |
); | |
export const mapAttributes = R.compose( | |
averageAttributes, | |
sumAttributes, | |
extractAttributes | |
); | |
export default fetchAttributes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment