Merge pull request #3914 from overleaf/jel-graphs-cached-licenses

Use cached affiliation data

GitOrigin-RevId: b8ae2b871cc1f3a11e61dd449b4d1ddc7835860d
This commit is contained in:
Jessica Lawshe 2021-04-26 09:31:35 -05:00 committed by Copybot
parent 4e9d7c36ff
commit 517485d7ea
2 changed files with 0 additions and 64 deletions

View file

@ -1,7 +1,6 @@
const metrics = require('@overleaf/metrics')
const AnalyticsManager = require('./AnalyticsManager')
const AuthenticationController = require('../Authentication/AuthenticationController')
const InstitutionsAPI = require('../Institutions/InstitutionsAPI')
const GeoIpLookup = require('../../infrastructure/GeoIpLookup')
const Features = require('../../infrastructure/Features')
@ -35,35 +34,5 @@ module.exports = {
AuthenticationController.getLoggedInUserId(req) || req.sessionID
AnalyticsManager.recordEvent(userId, req.params.event, req.body)
res.sendStatus(202)
},
licences(req, res, next) {
InstitutionsAPI.getInstitutionLicences(
req.query.resource_id,
req.query.start_date,
req.query.end_date,
req.query.lag,
function (error, licences) {
if (error) {
return next(error)
}
res.send(licences)
}
)
},
newLicences(req, res, next) {
InstitutionsAPI.getInstitutionNewLicences(
req.query.resource_id,
req.query.start_date,
req.query.end_date,
req.query.lag,
function (error, licences) {
if (error) {
return next(error)
}
res.send(licences)
}
)
}
}

View file

@ -15,10 +15,6 @@ describe('AnalyticsController', function () {
recordEvent: sinon.stub()
}
this.InstitutionsAPI = {
getInstitutionLicences: sinon.stub().callsArgWith(4)
}
this.Features = {
hasFeature: sinon.stub().returns(true)
}
@ -28,7 +24,6 @@ describe('AnalyticsController', function () {
'./AnalyticsManager': this.AnalyticsManager,
'../Authentication/AuthenticationController': this
.AuthenticationController,
'../Institutions/InstitutionsAPI': this.InstitutionsAPI,
'../../infrastructure/Features': this.Features,
'../../infrastructure/GeoIpLookup': (this.GeoIpLookup = {
getDetails: sinon.stub()
@ -94,32 +89,4 @@ describe('AnalyticsController', function () {
done()
})
})
describe('licences', function () {
beforeEach(function () {
this.req = {
query: {
resource_id: 1,
start_date: '1514764800',
end_date: '1530662400',
resource_type: 'institution'
},
sessionID: 'sessionIDHere',
session: {}
}
})
it('should trigger institutions api to fetch licences graph data', function (done) {
this.controller.licences(this.req, this.res)
this.InstitutionsAPI.getInstitutionLicences
.calledWith(
this.req.query.resource_id,
this.req.query.start_date,
this.req.query.end_date,
this.req.query.lag
)
.should.equal(true)
done()
})
})
})