Parallel creations
This commit is contained in:
parent
0c77cf2b40
commit
69527cd4b9
|
@ -25,11 +25,10 @@ async function run() {
|
||||||
}
|
}
|
||||||
console.log(`Table found: ${studentsTable.name}`)
|
console.log(`Table found: ${studentsTable.name}`)
|
||||||
|
|
||||||
const studentsPromise = []
|
|
||||||
let studentNumber = studentsTable.schema["Auto ID"].lastID
|
let studentNumber = studentsTable.schema["Auto ID"].lastID
|
||||||
for (let i = 0; i < STUDENT_COUNT; i++) {
|
let i = 0
|
||||||
studentsPromise.push(
|
const students = await Promise.all(
|
||||||
(async () => {
|
Array.from({ length: STUDENT_COUNT }).map(async () => {
|
||||||
await createRow(apiKey, app._id, studentsTable, {
|
await createRow(apiKey, app._id, studentsTable, {
|
||||||
"Student Number": (++studentNumber).toString(),
|
"Student Number": (++studentNumber).toString(),
|
||||||
"First Name": generator.first(),
|
"First Name": generator.first(),
|
||||||
|
@ -42,15 +41,12 @@ async function run() {
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
`Student ${i + 1} of ${STUDENT_COUNT} created (${
|
`Student ${++i} of ${STUDENT_COUNT} created (${
|
||||||
(Date.now() - start) / 1000
|
(Date.now() - start) / 1000
|
||||||
}s)`
|
}s)`
|
||||||
)
|
)
|
||||||
})()
|
})
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
const students = await Promise.all(studentsPromise)
|
|
||||||
|
|
||||||
const subjectTable = await createTable(apiKey, app._id, {
|
const subjectTable = await createTable(apiKey, app._id, {
|
||||||
schema: {
|
schema: {
|
||||||
|
@ -63,23 +59,19 @@ async function run() {
|
||||||
primaryDisplay: "Name",
|
primaryDisplay: "Name",
|
||||||
})
|
})
|
||||||
|
|
||||||
const subjectPromises = []
|
i = 0
|
||||||
for (let i = 0; i < SUBJECT_COUNT; i++) {
|
const subjects = await Promise.all(
|
||||||
subjectPromises.push(
|
Array.from({ length: SUBJECT_COUNT }).map(async () => {
|
||||||
(async () => {
|
|
||||||
await createRow(apiKey, app._id, subjectTable, {
|
await createRow(apiKey, app._id, subjectTable, {
|
||||||
Name: generator.profession(),
|
Name: generator.profession(),
|
||||||
})
|
})
|
||||||
console.log(
|
console.log(
|
||||||
`Subject ${i + 1} of ${SUBJECT_COUNT} created (${
|
`Subject ${++i} of ${SUBJECT_COUNT} created (${
|
||||||
(Date.now() - start) / 1000
|
(Date.now() - start) / 1000
|
||||||
}s)`
|
}s)`
|
||||||
)
|
)
|
||||||
})()
|
})
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
const subjects = await Promise.all(subjectPromises)
|
|
||||||
|
|
||||||
const gradesTable = await createTable(apiKey, app._id, {
|
const gradesTable = await createTable(apiKey, app._id, {
|
||||||
schema: {
|
schema: {
|
||||||
|
@ -113,7 +105,7 @@ async function run() {
|
||||||
name: "Grades",
|
name: "Grades",
|
||||||
})
|
})
|
||||||
|
|
||||||
let i = 0
|
i = 0
|
||||||
for (const student of students) {
|
for (const student of students) {
|
||||||
for (const subject of subjects) {
|
for (const subject of subjects) {
|
||||||
await createRow(apiKey, app._id, gradesTable, {
|
await createRow(apiKey, app._id, gradesTable, {
|
||||||
|
|
Loading…
Reference in New Issue