Просмотр исходного кода

Merge pull request #2079 from overleaf/ta-institution-new-licences

Add Routing for New Licences Metrics Graph

GitOrigin-RevId: 9e7def383d257db1eef03b1224b4b5fef376427c
Eric Mc Sween 7 лет назад
Родитель
Сommit
0e8866f651

+ 15 - 0
services/web/app/src/Features/Analytics/AnalyticsController.js

@@ -48,6 +48,21 @@ module.exports = {
         res.send(licences)
         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)
+      }
+    )
   }
   }
 }
 }
 
 

+ 15 - 0
services/web/app/src/Features/Institutions/InstitutionsAPI.js

@@ -48,6 +48,21 @@ module.exports = InstitutionsAPI = {
     )
     )
   },
   },
 
 
+  getInstitutionNewLicences(institutionId, startDate, endDate, lag, callback) {
+    if (callback == null) {
+      callback = function(error, body) {}
+    }
+    return makeAffiliationRequest(
+      {
+        method: 'GET',
+        path: `/api/v2/institutions/${institutionId.toString()}/new_institution_licences`,
+        body: { start_date: startDate, end_date: endDate, lag },
+        defaultErrorMessage: "Couldn't get institution new licences"
+      },
+      callback
+    )
+  },
+
   getUserAffiliations(userId, callback) {
   getUserAffiliations(userId, callback) {
     if (callback == null) {
     if (callback == null) {
       callback = function(error, body) {}
       callback = function(error, body) {}