Skip to content

[Frontend] - Add scripts for mock data initialization and database wiping - #439

Merged
thomasdejaeghere merged 4 commits into
developmentfrom
410-frontend---add-scripts-for-mock-data-initialization-and-database-wiping
Apr 23, 2025
Merged

[Frontend] - Add scripts for mock data initialization and database wiping#439
thomasdejaeghere merged 4 commits into
developmentfrom
410-frontend---add-scripts-for-mock-data-initialization-and-database-wiping

Conversation

@rvdkeere

@rvdkeere rvdkeere commented Apr 14, 2025

Copy link
Copy Markdown
Contributor

Adds new scripts for putting random mock data in the database, and for wiping the database tables clean. These scripts can be run manually, but the functions called by them are exported separately and can be used for other testing purposes as well. They are located in backend/extra.

The clear script truncates all tables and can be manually run with:
docker-compose exec backend npm run db:clear

The seed script clears the db first and then fills it with new data. It can be manually run with:
docker-compose exec backend npm run db:seed

The current implementation of seedDatabase uses faker-js to generate random data in fields like names and descriptions.
Feedback on this mechanism is welcome, for example if you want some accounts or classes with fixed names, let me know and I will add them separately. The benefit of using faker here is that you have a more flexible amount of entities, since you can easily edit the seed file to include however many entities you want of each type.

Emails are handled differently: they use a fixed format of {nr}.{student/teacher}.ugent.be where nr is any number from 1 to 5 for teachers and from 1 to 20 for students.
For every account, the password is "asdf1234" to make it easy to log in during demos or manual testing.

@rvdkeere rvdkeere added enhancement New feature or request frontend backend labels Apr 14, 2025
@rvdkeere rvdkeere added this to the Milestone 2 milestone Apr 14, 2025
@rvdkeere rvdkeere self-assigned this Apr 14, 2025
@rvdkeere rvdkeere mentioned this pull request Apr 14, 2025
5 tasks
Comment thread backend/extra/clearDatabase.ts
Comment thread backend/extra/runClearDb.ts Outdated
@rvdkeere rvdkeere added the dependencies Pull requests that update a dependency file label Apr 14, 2025
@rvdkeere
rvdkeere marked this pull request as ready for review April 16, 2025 13:55

@lennertdr lennertdr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe walk us through in the meeting this evening

@rvdkeere
rvdkeere marked this pull request as draft April 21, 2025 17:45
added name to assignments
@rvdkeere
rvdkeere marked this pull request as ready for review April 22, 2025 17:40
@thomasdejaeghere
thomasdejaeghere merged commit d849a89 into development Apr 23, 2025
@@ -0,0 +1,275 @@
/**
* 🌱 Seed function: Random Database Seeder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@bramcomyn
bramcomyn deleted the 410-frontend---add-scripts-for-mock-data-initialization-and-database-wiping branch May 10, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend dependencies Pull requests that update a dependency file enhancement New feature or request frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants