Skip to content
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

Fix/clean transfert permissions ALL TO MONTORING_XXX #291

Merged
merged 3 commits into from
Jan 26, 2024

Conversation

amandine-sahl
Copy link
Contributor

Lors de la migration alembic, la répercussion de la gestion des permissions (avec des sous_objets) utilisait une fonction.

Cela pose des soucis de lock de la table gn_module (plus des potientels problèmes de maintenance de la fonction) qui empechait la réalisation des migations suivantes.

Pour résoudre ce soucis, nous avons finalement utilisé une commande qui permet la migration des permissions existantes dans les instances.

@amandine-sahl amandine-sahl changed the base branch from main to dev-suivi-eolien January 19, 2024 15:36
@camillemonchicourt
Copy link
Member

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

CodiumAI-Agent commented Jan 19, 2024

PR Analysis

(review updated until commit 8f7d439)

  • 🎯 Main theme: Refactoring permission management in the monitoring module
  • 📝 PR summary: This PR addresses issues with permission management during alembic migration. It replaces a function with a command to migrate existing permissions in instances, which resolves table lock issues and potential maintenance problems. The PR also includes code to clean existing permissions and update associated module objects.
  • 📌 Type of PR: Bug fix
  • 🧪 Relevant tests added: No
  • ⏱️ Estimated effort to review [1-5]: 4, because the PR involves changes in the permission management system which requires a good understanding of the existing system and the proposed changes. The changes are spread across multiple files and involve SQL queries.
  • 🔒 Security concerns: Yes, because the PR includes raw SQL queries which could potentially be vulnerable to SQL injection attacks if not properly sanitized.

PR Feedback

💡 General suggestions: The PR addresses a critical issue in the permission management system and the approach seems to be sound. However, it would be beneficial to add some tests to ensure that the new permission management system works as expected and does not introduce new issues.


✨ Usage guide:

Overview:
The review tool scans the PR code changes, and generates a PR review. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:

/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...

With a configuration file, use the following template:

[pr_reviewer]
some_config1=...
some_config2=...
Utilizing extra instructions

The review tool can be configured with extra instructions, which can be used to guide the model to a feedback tailored to the needs of your project.

Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Specify the relevant sub-tool, and the relevant aspects of the PR that you want to emphasize.

Examples for extra instructions:

[pr_reviewer] # /review #
extra_instructions="""
In the code feedback section, emphasize the following:
- Does the code logic cover relevant edge cases?
- Is the code logic clear and easy to understand?
- Is the code logic efficient?
...
"""

Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.

How to enable\disable automation
  • When you first install PR-Agent app, the default mode for the review tool is:
pr_commands = ["/review", ...]

meaning the review tool will run automatically on every PR, with the default configuration.
Edit this field to enable/disable the tool, or to change the used configurations

About the 'Code feedback' section

The review tool provides several type of feedbacks, one of them is code suggestions.
If you are interested only in the code suggestions, it is recommended to use the improve feature instead, since it dedicated only to code suggestions, and usually gives better results.
Use the review tool if you want to get a more comprehensive feedback, which includes code suggestions as well.

Auto-labels

The review tool can auto-generate two specific types of labels for a PR:

  • a possible security issue label, that detects possible security issues (enable_review_labels_security flag)
  • a Review effort [1-5]: x label, where x is the estimated effort to review the PR (enable_review_labels_effort flag)
Extra sub-tools

The review tool provides a collection of possible feedbacks about a PR.
It is recommended to review the possible options, and choose the ones relevant for your use case.
Some of the feature that are disabled by default are quite useful, and should be considered for enabling. For example:
require_score_review, require_soc2_review, enable_review_labels_effort, and more.

More PR-Agent commands

To invoke the PR-Agent, add a comment using one of the following commands:

  • /review: Request a review of your Pull Request.
  • /describe: Update the PR title and description based on the contents of the PR.
  • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
  • /ask <QUESTION>: Ask a question about the PR.
  • /update_changelog: Update the changelog based on the PR's contents.
  • /add_docs 💎: Generate docstring for new components introduced in the PR.
  • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
  • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

See the tools guide for more details.
To list the possible configuration parameters, add a /config comment.

See the review usage page for a comprehensive guide on using this tool.

@CodiumAI-Agent
Copy link

Persistent review updated to latest commit 8f7d439

backend/gn_module_monitoring/command/cmd.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
@camillemonchicourt
Copy link
Member

@CodiumAI-Agent /improve

backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/cmd.py Outdated Show resolved Hide resolved
backend/gn_module_monitoring/command/utils.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ccd3cc8) 71.63% compared to head (a0ab27f) 71.67%.
Report is 1 commits behind head on dev-suivi-eolien.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           dev-suivi-eolien     #291      +/-   ##
====================================================
+ Coverage             71.63%   71.67%   +0.03%     
====================================================
  Files                    31       31              
  Lines                  2193     2196       +3     
====================================================
+ Hits                   1571     1574       +3     
  Misses                  622      622              
Flag Coverage Δ
pytest 71.67% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

docs/changelog.md Show resolved Hide resolved
docs/changelog.md Show resolved Hide resolved
@amandine-sahl amandine-sahl added this to the Sites multiprotocole milestone Jan 26, 2024
@amandine-sahl amandine-sahl force-pushed the fix/clean_transfert_permissions branch from dcee9ad to a0ab27f Compare January 26, 2024 10:55
@amandine-sahl amandine-sahl merged commit 545883b into dev-suivi-eolien Jan 26, 2024
7 checks passed
@amandine-sahl amandine-sahl deleted the fix/clean_transfert_permissions branch January 26, 2024 11:27
andriacap pushed a commit to naturalsolutions/gn_module_monitoring that referenced this pull request Jul 5, 2024
* Script sql de migration des permissions

* Changelog
amandine-sahl added a commit that referenced this pull request Jul 29, 2024
* Script sql de migration des permissions

* Changelog
amandine-sahl added a commit that referenced this pull request Oct 4, 2024
Remove export as csv test

Fix/migrations (#285)

* Move create cor_type_site bib_type_site cor_module_type to geonature

* Remove id_nomenclature_type_site and migrate model to GeoNature

* Move t_observations to GeoNature

* Rename cor_type_site to cor_site_type

* Bump GeoNature

db downgrade does not work with data (#280)

Fix test export route (#293)

fix: organism_actors attributes

fix: clean python files imports + BLACK 24 (#290)

* fix: remove relative imports and unused libs

* fix: remove unused modules

* Add import fixture monitoring_users

* Reorder imports

* Black

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>

fix: use table models migrated in geonature core BibTypesSites (#292)

* fix: use table models migrated in geonature core

* fix: imports in tests files

* Import TNomenclature from pypnnomenclature

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>

Fix/clean transfert permissions ALL TO MONTORING_XXX (#291)

* Script sql de migration des permissions

* Changelog

Fix : sqlalchemy query

Fix/detail site url - cf #298 (#299)

* Correction url lien vers détail site

* Harmonisation popup carto

Fix/synchro on synthese (#288)

* remove silented errors when insert in synthese

* add migration for trigger delete in synthese
---------

Co-authored-by: amandine-sahl <[email protected]>

Feat/multiple geom type (#296)

* allow multiple geom type

* Sites avec plusieurs type de géométrie par défaut

---------

Co-authored-by: amandine-sahl <[email protected]>

Correction affichage propriétés spécifiques - cf #303 (#304)

Fix : migration modification for permissions (#305)

* Fix : migration modification for permissions

Ajout interaction carte liste (#300)

Fix downgrade declare available types sites

feat: add unit tests for generic monitoring routes and utils (#295)

* feat: add test for config route

* feat: add data_utils tests

* fix: response code for data utils route

* fix: rename test to match source file

* fix: remove useless file

* fix: remove legacy code

* feat: add tests for utils and error

Harmonisation des processus d'exécution de sql (#308)

* Harmonisation des processus d'exécution de sql

* Add test forbidden sql instructions

fix: filter ,sort and page on datatable (#310)

* fix: filter ,sort and page on datatable

Missing changes to check according to event on table(sort, filter, page)
Refact code for ngOnChanges

Reviewed-by: andriac

* style(front): apply prettier

Reviewed-by: andriacap
amandine-sahl added a commit that referenced this pull request Oct 4, 2024
feat: manage geom through protocol

- Fix bug changeActiveTab
- Add displaying conditional site group geometry through protocol

Reviewed-by: andriacap

fix: create site group without geom

Reviewed-by: andriacap

hotfix: remove import AppConfig

Error when using docker build

Reviewed-by: andriacap

Resolve conflicts

Use load_default for marshmallow schema - cf #268

 add id_digititer to generic observation.json  - cf #274

fix migrations downgrade - cf #269

create site with type without custom properties - cf #266

Correction frontend

[frontend] Style margin and map height - cf #270

fix site not visible in visit (#272)

fix error on site create from module (#275)

fix site property not displayed (#277)

lint prettier 3.1.0 (#278)

Remove laizy joined

Correction yml

Correction fixture sites

Add asset type de site (#282)

* Add asset type de site

Lint prettier (#281)

* Lint prettier 3.1.0

add dev-suivi-eolien in pytest.yml

[SqlAlchemy 1.4] compat sqlalchemy 1.4

Corrections + Ajout de  tests

Remove export as csv test

Fix/migrations (#285)

* Move create cor_type_site bib_type_site cor_module_type to geonature

* Remove id_nomenclature_type_site and migrate model to GeoNature

* Move t_observations to GeoNature

* Rename cor_type_site to cor_site_type

* Bump GeoNature

db downgrade does not work with data (#280)

Fix test export route (#293)

fix: organism_actors attributes

fix: clean python files imports + BLACK 24 (#290)

* fix: remove relative imports and unused libs

* fix: remove unused modules

* Add import fixture monitoring_users

* Reorder imports

* Black

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>

fix: use table models migrated in geonature core BibTypesSites (#292)

* fix: use table models migrated in geonature core

* fix: imports in tests files

* Import TNomenclature from pypnnomenclature

---------

Co-authored-by: Mathieu ROUDAUT <[email protected]>
Co-authored-by: amandine-sahl <[email protected]>

Fix/clean transfert permissions ALL TO MONTORING_XXX (#291)

* Script sql de migration des permissions

* Changelog

Fix : sqlalchemy query

Fix/detail site url - cf #298 (#299)

* Correction url lien vers détail site

* Harmonisation popup carto

Fix/synchro on synthese (#288)

* remove silented errors when insert in synthese

* add migration for trigger delete in synthese
---------

Co-authored-by: amandine-sahl <[email protected]>

Feat/multiple geom type (#296)

* allow multiple geom type

* Sites avec plusieurs type de géométrie par défaut

---------

Co-authored-by: amandine-sahl <[email protected]>

Correction affichage propriétés spécifiques - cf #303 (#304)

Fix : migration modification for permissions (#305)

* Fix : migration modification for permissions

Ajout interaction carte liste (#300)

Fix downgrade declare available types sites

feat: add unit tests for generic monitoring routes and utils (#295)

* feat: add test for config route

* feat: add data_utils tests

* fix: response code for data utils route

* fix: rename test to match source file

* fix: remove useless file

* fix: remove legacy code

* feat: add tests for utils and error

Harmonisation des processus d'exécution de sql (#308)

* Harmonisation des processus d'exécution de sql

* Add test forbidden sql instructions

fix: filter ,sort and page on datatable (#310)

* fix: filter ,sort and page on datatable

Missing changes to check according to event on table(sort, filter, page)
Refact code for ngOnChanges

Reviewed-by: andriac

* style(front): apply prettier

Reviewed-by: andriacap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants