France-ioi / AlgoreaBackend

Backend for the new Algorea platform
MIT License
1 stars 2 forks source link

userViewById: add whether we can view/edit his personnal info #1091

Closed GeoffreyHuck closed 1 month ago

GeoffreyHuck commented 1 month ago

fixes #1090

Add personal_info_access_approval_to_current_user in the response, which is the max value among the groups for which both the current user is implicitly manager of, and the user requested is descendant of.

Notes:

Implementation

We already get the list of groups of which the current-user is a manager and of which the user is a descendant of (for the field ancestors_current_user_is_manager_of). So to avoid doing another query for this, the values of require_personal_info_access_approval were added in the select of the existing query.

Then, with the result of the query, we fill the groups information and we compute the max.

Another way of doing would have been to create a query just for it, but since it requires to check the same groups as ancestors_current_user_is_manager_of, we would have done almost the same work twice.

Query index

Only added a field in the select, so there's no need for a new index.

Review

Probably easier all at once because there are a few refactoring to make the code clearer.

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (2e03f87) to head (85ba358).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1091 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 239 239 Lines 14384 14406 +22 ========================================= + Hits 14384 14406 +22 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.