@byu-oit/canvas-sdk
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -13,2 +13,3 @@ 'use strict'; | ||
const STARTING_RATE_LIMIT_REMAINING = 700; | ||
const DEFAULT_MAX_SIMULTANEOUS_REQUESTS = 10; | ||
@@ -18,2 +19,4 @@ module.exports = function(config) { | ||
canvas.maxSimultaneousRequests = config.maxSimultaneousRequests || DEFAULT_MAX_SIMULTANEOUS_REQUESTS; | ||
if(config.tokens) { | ||
@@ -20,0 +23,0 @@ canvas.tokens = []; |
{ | ||
"name": "@byu-oit/canvas-sdk", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "A wrapper around Instructure's Canvas API", | ||
@@ -33,2 +33,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"promise-subarrays": "^0.1.1", | ||
"request": "^2.87.0", | ||
@@ -35,0 +36,0 @@ "request-promise": "^4.2.2", |
'use strict'; | ||
const logger = require('./utils/logger'); | ||
const uuid = require('uuid'); | ||
const PromiseArray = require('promise-subarrays'); | ||
@@ -41,11 +42,17 @@ module.exports = function(canvas) { | ||
const sections = []; | ||
const promiseArray = PromiseArray(); | ||
for(let course of courses) { | ||
logger.info(`Getting sections for course ${course.sis_course_id}`); | ||
const courseSections = await canvas.requestAll(`courses/${course.id}/sections?include=students`); | ||
for(let courseSection of courseSections) { | ||
courseSection.account_id = course.account_id; | ||
courseSection.workflow_state = course.workflow_state; | ||
sections.push(courseSection); | ||
} | ||
promiseArray.push(async function(course) { | ||
logger.info(`Getting sections for course ${course.sis_course_id}`); | ||
const courseSections = await canvas.requestAll(`courses/${course.id}/sections?include=students`); | ||
for(let courseSection of courseSections) { | ||
courseSection.account_id = course.account_id; | ||
courseSection.workflow_state = course.workflow_state; | ||
sections.push(courseSection); | ||
} | ||
}, [course]); | ||
} | ||
await promiseArray.awaitAll(canvas.maxSimultaneousRequests); | ||
return sections; | ||
@@ -52,0 +59,0 @@ }; |
@@ -8,3 +8,4 @@ 'use strict'; | ||
token: process.env.TOKEN, | ||
subdomain: process.env.SUBDOMAIN | ||
subdomain: process.env.SUBDOMAIN, | ||
maxSimultaneousRequests: 5 | ||
}); | ||
@@ -11,0 +12,0 @@ const logger = require('./src/utils/logger'); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49880
811
4
+ Addedpromise-subarrays@^0.1.1
+ Addedpromise-subarrays@0.1.2(transitive)
+ Addedpsl@1.13.0(transitive)
- Removedpsl@1.14.0(transitive)