review fixes and moving licences endpoint to module

This commit is contained in:
hugh-obrien 2018-08-23 14:39:48 +01:00
parent 8d72fc78fc
commit bd721d52f4
3 changed files with 2 additions and 5 deletions

View file

@ -25,11 +25,10 @@ module.exports = AnalyticsController =
respondWith(error, res, next) respondWith(error, res, next)
licences: (req, res, next) -> licences: (req, res, next) ->
AuthenticationController.getLoggedInUserId(req) or req.sessionID
{resource_id, start_date, end_date, lag} = req.query {resource_id, start_date, end_date, lag} = req.query
InstitutionsAPI.getInstitutionLicences resource_id, start_date, end_date, lag, (error, licences) -> InstitutionsAPI.getInstitutionLicences resource_id, start_date, end_date, lag, (error, licences) ->
if error? if error?
res.send 503 next(error)
else else
res.send licences res.send licences

View file

@ -9,8 +9,6 @@ module.exports =
webRouter.put '/editingSession/:projectId', webRouter.put '/editingSession/:projectId',
AnalyticsController.updateEditingSession AnalyticsController.updateEditingSession
webRouter.get '/graphs/licences', AnalyticsController.licences
publicApiRouter.use '/analytics/graphs', publicApiRouter.use '/analytics/graphs',
AuthenticationController.httpAuth, AuthenticationController.httpAuth,
AnalyticsProxy.call('/graphs') AnalyticsProxy.call('/graphs')

View file

@ -16,7 +16,7 @@ module.exports = InstitutionsAPI =
method: 'GET' method: 'GET'
path: "/api/v2/institutions/#{institutionId.toString()}/institution_licences" path: "/api/v2/institutions/#{institutionId.toString()}/institution_licences"
body: {start_date: startDate, end_date: endDate, lag} body: {start_date: startDate, end_date: endDate, lag}
defaultErrorMessage: "Couldn't get institution affiliations" defaultErrorMessage: "Couldn't get institution licences"
}, callback }, callback
getUserAffiliations: (userId, callback = (error, body) ->) -> getUserAffiliations: (userId, callback = (error, body) ->) ->