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

New Data Model : Add an Organization table #332

Merged
merged 23 commits into from
Jul 15, 2024
Merged

New Data Model : Add an Organization table #332

merged 23 commits into from
Jul 15, 2024

Conversation

RonanMorgan
Copy link
Collaborator

@RonanMorgan RonanMorgan commented Jun 17, 2024

This table will be used to keep information about the owner of one or many cameras.

It will also be useful for resources access management (if you have access to the Site, you have access to all the resources linked to this site)

Pyronear UML

@RonanMorgan RonanMorgan requested a review from frgfm June 17, 2024 16:21
@RonanMorgan
Copy link
Collaborator Author

RonanMorgan commented Jun 17, 2024

TODO :
=> add site_id in user table ✔️
=> add other CRUD functionalities for the Site endpoint and add tests for them ✔️
=> refactor Site -> Organization ✔️
=> adapt access behavior : a user can only access resources from the same site ✔️

  • cameras ✔️
  • detections ✔️
  • users -> no refactor needed since only the ADMIN scope can use this endpoint

=> fix e2e tests & client tests ✔️
=> improve tests coverage

Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 81.35593% with 22 lines in your changes missing coverage. Please review.

Project coverage is 87.71%. Comparing base (2dcab5b) to head (10f9f7e).

Files Patch % Lines
src/app/db.py 7.69% 12 Missing ⚠️
src/app/api/api_v1/endpoints/cameras.py 76.92% 3 Missing ⚠️
src/app/api/api_v1/endpoints/detections.py 88.88% 3 Missing ⚠️
src/app/crud/base.py 60.00% 2 Missing ⚠️
client/pyroclient/client.py 50.00% 1 Missing ⚠️
src/app/api/api_v1/endpoints/login.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #332      +/-   ##
==========================================
- Coverage   88.49%   87.71%   -0.78%     
==========================================
  Files          28       31       +3     
  Lines         643      741      +98     
==========================================
+ Hits          569      650      +81     
- Misses         74       91      +17     
Flag Coverage Δ
backend 87.33% <81.73%> (-0.67%) ⬇️
client 93.47% <66.66%> (-1.88%) ⬇️

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.

@github-actions github-actions bot added topic: docs Improvements or additions to documentation topic: docker ext: client/tests module: core labels Jun 19, 2024
@RonanMorgan RonanMorgan changed the title New Data Model : Add a Site table New Data Model : Add an Organization table Jun 21, 2024
Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
Just a few high-level questions:

  • whether admin should below to an org
  • what you should be able to access when you're not in the org of the specific resource

The simple version in my mind is that org = ID + name, and we add organization_id to users & cameras table. Either we can create a pyronear org or consider that a resource without an org ID is an admin. What do you think?

@RonanMorgan
Copy link
Collaborator Author

@frgfm about the pyronear org : it seems dangerous to me to say that an empty org has the admin right, it would be easy to imagine a bug conducting to the creation of an empty org that's why I don't really like this solution (but I might be wrong)

furthermore we could imagine some development resources only available to pyronear member, in this case we could also have non admin user attached to the pyronear org.

Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks for the edits! Lengthy review I'm sorry, but I did spot a few issues here and there + added some discussion questions

Let me know what you think 👍

Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Feels almost finalized, just a few details 🙂

@github-actions github-actions bot added the topic: build Related to build, installation & CI label Jul 11, 2024
@RonanMorgan RonanMorgan requested a review from frgfm July 11, 2024 15:28
Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks for the edits! High-level comments:

  • there are still problems with the value put in the JWT payload. This is important, we need to pay attention to this so we can trust it later
  • the new CRUD method could be very simple extensions of fetch_all
  • watch out for search & replace all, you wanted to change 1-2 files, but you edited everything (and those should be reverted)

Almost there 🤞

@RonanMorgan RonanMorgan requested a review from frgfm July 12, 2024 08:31
Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Looks like there is only a blank line + a rebase/merge to resolve conflicts and we're good to go :)

@RonanMorgan RonanMorgan requested a review from frgfm July 12, 2024 20:38
@frgfm
Copy link
Member

frgfm commented Jul 13, 2024

There are still conflicts, but it's strange the last commit on main was 18hours ago, while your last push is from 12 hours ago. Are you merging the last version of main?

Copy link
Member

@frgfm frgfm left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@frgfm frgfm merged commit ca23c40 into main Jul 15, 2024
24 of 27 checks passed
@frgfm frgfm deleted the rs/add-site-table branch July 15, 2024 10:03
@frgfm
Copy link
Member

frgfm commented Aug 24, 2024

cf. #304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants