In this PR we add the ability to describe a capacity per-user when creating a new common or editing it. This change introduces a new field on the create and edit commons form that gives the admin the ability to specify a per-user capacity for each commons.
It utilizes the following formula to calculate the effective capacity of the common when doing health calculations
max(capacityPerUser * numUsers, carryingCapacity)
Screenshots
New Create and Update Form:
Effective Capacity with One User in the common
Effective Capacity with Two Users in the common
With 12 cows in the common health updating job does not diminish cow health
With 12 cows in the common, and one user is removed, the health updating job diminishes cow health
Validation (Optional)
Download this branch.
Run the project.
Go to this page.
Test this function.
Feedback Requests
The way I implemented this feature was by creating a new private and Non-serializable variable in the Commons entity, and every time a user joins or is deleted from a common the variable is updated. This was due to the fact that you can't reference repositories inside the entity in order to get the user count. If you have any suggestions on how to improve this solution that will be appreciated.
Tests
[x] Backend Unit tests (mvn test) pass
[x] Backend Test coverage (mvn test jacoco:report) 100%
[x] Backend Mutation tests (mvn test pitest:mutationCoverage) 100%
[x] Frontend Unit tests (npm test) pass
[x] Frontend Test coverage (npm run coverage) 100%
Overview
In this PR we add the ability to describe a capacity per-user when creating a new common or editing it. This change introduces a new field on the create and edit commons form that gives the admin the ability to specify a per-user capacity for each commons.
It utilizes the following formula to calculate the effective capacity of the common when doing health calculations
max(capacityPerUser * numUsers, carryingCapacity)
Screenshots
New Create and Update Form:
Effective Capacity with One User in the common
Effective Capacity with Two Users in the common
With 12 cows in the common health updating job does not diminish cow health
With 12 cows in the common, and one user is removed, the health updating job diminishes cow health
Validation (Optional)
Feedback Requests
The way I implemented this feature was by creating a new private and Non-serializable variable in the Commons entity, and every time a user joins or is deleted from a common the variable is updated. This was due to the fact that you can't reference repositories inside the entity in order to get the user count. If you have any suggestions on how to improve this solution that will be appreciated.
Tests
mvn test
) passmvn test jacoco:report
) 100%mvn test pitest:mutationCoverage
) 100%npm test
) passnpm run coverage
) 100%npx stryker run
) 100%npx eslint --fix src
)Linked Issues
Closes #3