-
Notifications
You must be signed in to change notification settings - Fork 0
Stress test more data & add server pagination/filtering/sorting #592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
70f79d7
c7daa84
076ccb6
f983f65
c9595be
f94c70a
7709e3a
ee45b5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { ParticipantProfile, StudyParticipant, SurveyVersionAnswers } from '@prisma/client' | ||
| import { createDefaultAnswers } from '../src/utils/answers' | ||
| import prisma from '../src/PrismaClient' | ||
| import { faker } from '@faker-js/faker' | ||
|
|
||
| const main = async () => { | ||
| // Get number of records from command line argument, fallback to 1000 | ||
| const numRecords = process.argv[2] ? parseInt(process.argv[2], 10) : 1000 | ||
| if (isNaN(numRecords) || numRecords <= 0) { | ||
| console.error('Please provide a valid positive integer for the number of records.') | ||
| process.exit(1) | ||
| } | ||
|
|
||
| //eslint-disable-next-line | ||
| const SeedSurveyStepData = require('../prisma/seed/seedSurveyStepData.json') | ||
| const exampleAnswers = createDefaultAnswers(SeedSurveyStepData) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried with 10000 participants and the responses page was not slow :) do you think this is due to it being a simpler query? Is there value in using faker to generate a mix of different answers, as well as some non-responses (not as part of this PR)?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it is because the participants list pings the database once for every record, whereas the the responses page does it all at once.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| const participants: Partial<StudyParticipant>[] = [] | ||
| const profiles: Partial<ParticipantProfile>[] = [] | ||
| const answers: Partial<SurveyVersionAnswers>[] = [] | ||
| for (let i = 0; i < numRecords; i++) { | ||
| const pData: Partial<ParticipantProfile> = { | ||
| id: 1000 + i, | ||
| addressLine: faker.string.alphanumeric(), | ||
| dob: faker.date.birthdate(), | ||
| firstName: faker.person.firstName(), | ||
| lastName: faker.person.lastName(), | ||
| mobile: faker.phone.number(), | ||
| participantType: 'STANDARD', | ||
| postcode: '1234', | ||
| preferredContact: 'EMAIL', | ||
| state: 'ACT', | ||
| suburb: 'SUBURB', | ||
| } | ||
| profiles.push(pData) | ||
| participants.push({ | ||
| participantId: faker.string.uuid(), | ||
| participantProfileId: 1000 + i, | ||
| studyId: 1, | ||
| participantNumber: 1000 + i, | ||
| }) | ||
|
|
||
| answers.push({ profileId: 1000 + i, versionId: 1000, answers: exampleAnswers }) | ||
| } | ||
| await prisma.participantProfile.createMany({ data: profiles as any }) | ||
| await prisma.studyParticipant.createMany({ data: participants as any }) | ||
| await prisma.surveyVersionAnswers.createMany({ data: answers as any }) | ||
| } | ||
|
|
||
| main() | ||
Uh oh!
There was an error while loading. Please reload this page.