-
Notifications
You must be signed in to change notification settings - Fork 0
Complete Role and Generation seeders #244
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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR completes the Role and Generation seeders by enhancing the seeding logic to properly associate roles with activities and generations. It updates the role names and permissions in the RoleSeeder, adds logic to assign roles to activities in the PerActivityRoleSeeder, and implements role distribution across generations with priority given to the latest generation.
Key Changes:
- Modified role definitions with new names and updated permissions structure
- Enhanced PerActivityRoleSeeder to randomly assign existing roles and activities to PerActivityRole entities
- Added role assignment logic to GenerationSeeder that distributes roles across generations, giving extra roles to the latest generation
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| RoleSeeder.kt | Updates role names from "President", "Vice President" to "Board", "Member", "Coordinator" with adjusted permissions |
| PerActivityRoleSeeder.kt | Adds dependency injection for repositories and logic to randomly assign roles and activities to PerActivityRole entities |
| GenerationSeeder.kt | Implements role distribution logic across generations with priority for the latest generation |
| ApplicationSeeder.kt | Comments out PerActivityRoleSeeder execution in the main application seeder |
| ActivitySeeder.kt | Reorders seeder execution to run PerActivityRoleSeeder after other activity seeders |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/kotlin/pt/up/fe/ni/website/backend/model/seeders/PerActivityRoleSeeder.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/pt/up/fe/ni/website/backend/model/seeders/PerActivityRoleSeeder.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/pt/up/fe/ni/website/backend/model/seeders/GenerationSeeder.kt
Show resolved
Hide resolved
|
Check the documentation preview: https://68bc50d85692b99dd817f324--niaefeup-backend-docs.netlify.app |
|
Check the documentation preview: https://68bc50ffa1d6bda9fe3f095e--niaefeup-backend-docs.netlify.app |
src/main/kotlin/pt/up/fe/ni/website/backend/model/seeders/ApplicationSeeder.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/pt/up/fe/ni/website/backend/model/seeders/ApplicationSeeder.kt
Outdated
Show resolved
Hide resolved
| // Shuffle roles and assign to generations | ||
| val shuffledRoles = allRoles.shuffled().toMutableList() | ||
| val updatedRoles = mutableListOf<Role>() | ||
|
|
||
| generations.forEachIndexed { index, generation -> | ||
| val count = rolesPerGen[index] | ||
| repeat(count) { | ||
| if (shuffledRoles.isNotEmpty()) { | ||
| val role = shuffledRoles.removeAt(0) | ||
| role.generation = generation | ||
| generation.roles.add(role) | ||
| updatedRoles.add(role) // Collect updated roles to save | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep the data more realistic, I think each generation should get a "full set" of roles. What I mean my that is that each generation should have a set accounts in the board, coordinators and members.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the scope of this PR, but this seeder populates the perActivityRoles list with some permissions that are not related to the Acitivies model, such as EDIT_ACCOUNT and DELETE_ACCOUNT.
|
Check the documentation preview: https://68e441fbc4314305ee69a96b--niaefeup-backend-docs.netlify.app |
Adds missing Roles and Activities to the
PerActivityRoleseeder. Adds Roles to theGenerationseeder, prioritizing giving more roles to the latest generationReview checklist