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

Client table #148

Closed
peterdudfield opened this issue Jul 31, 2024 · 14 comments
Closed

Client table #148

peterdudfield opened this issue Jul 31, 2024 · 14 comments
Assignees

Comments

@peterdudfield
Copy link
Contributor

Detailed Description

it would be nice to have a client table, which is joined to the sites table

Context

  • nice to know which sites belong to which client
  • we could make a n by n join with users too, but perhaps this could be in a later issue

Possible Implementation

  • add client table with, client_name
  • join with sites table
  • make migration
@Bvr4
Copy link
Contributor

Bvr4 commented Sep 10, 2024

Hello, I'd like to work on this issue. Can it be assigned to me ?

Do you want other fields than client_name ?

I assume that we'll need to create crud operations to this table, and maybe an edit_site_client function ?

@peterdudfield
Copy link
Contributor Author

I think client name is good. Perhaps tge created mixin would be good too

Yea, create abd edit function would be great

Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 13, 2024
Add clientSQL in splmodels, with client_name
Mapped relationships between Client and Site
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 13, 2024
@Bvr4
Copy link
Contributor

Bvr4 commented Sep 16, 2024

By browsing through the alembic history, I found that a client table used to exist, and has been dropped when the User and SiteGroup tables were created. Are you sure you want to reintroduce it ?

If so, can the client_uuid field in the site table can be nullalble ? If not, this will entail constraints on the production process so as not to block everything.

@peterdudfield
Copy link
Contributor Author

yea your are right @Bvr4, we used to have it, and then switched to user and sites.

We would like it back, and yes, making it nullable would be great, and then much easier to role out

Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 16, 2024
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 16, 2024
)

add function, tests, and edited sites fixture in conftest in order to have client informations in tests samples
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 17, 2024
@peterdudfield
Copy link
Contributor Author

It would be great to have a few functions

  • create_client
  • read_client from client_name, i like the option to create the client if it doesnt exist
  • edit_client
  • assign_site_to_client, this will make it easy to assign sites to certain client names

Feel free to split these up into different issues/ PRs if you want too, no pressure

Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 17, 2024
added create_client and edit_client functions, and related tests.
edited PVSiteEditMetadata pydantic model, so edit_site function can update the client_uuid.
edited create_site function, so it can set the client_uuid.
@Bvr4
Copy link
Contributor

Bvr4 commented Sep 17, 2024

OK, I was working on create_client and edit_client function today. I put them in write/user_and_site.py. But I wonder if it would be better in another file, like write/client.py ?

@peterdudfield
Copy link
Contributor Author

Thanks so much for this @Bvr4 . Yea I would go for a different file

Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 17, 2024
Moved the client functions from user_and_site.py to client.py
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 17, 2024
Added get_client_by_name function, and related tests. This function can create a new client if it doesn't exist.
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Sep 19, 2024
@Bvr4 Bvr4 mentioned this issue Sep 20, 2024
7 tasks
Bvr4 added a commit to Bvr4/pv-site-datamodel that referenced this issue Oct 8, 2024
peterdudfield added a commit that referenced this issue Oct 13, 2024
* Add client table (#148)
Add clientSQL in splmodels, with client_name
Mapped relationships between Client and Site

* Alembic migration : Add client table (#148)

* Fix: make client_uuid nullable in Site table (#148)

* Add read function get_sites_by_client_name and tests (#148)
add function, tests, and edited sites fixture in conftest in order to have client informations in tests samples

* update readme Database schema (#148)

* Add create_client and edit_client functions (#148)
added create_client and edit_client functions, and related tests.
edited PVSiteEditMetadata pydantic model, so edit_site function can update the client_uuid.
edited create_site function, so it can set the client_uuid.

* Move create_client and edit_client to a new file (#148)
Moved the client functions from user_and_site.py to client.py

* Add get_client_by_name function (#148)
Added get_client_by_name function, and related tests. This function can create a new client if it doesn't exist.

* Add assign_site_to_client function (#148)

* Adjust alembic migration (#148)

---------

Co-authored-by: Peter Dudfield <[email protected]>
@peterdudfield
Copy link
Contributor Author

Thanks for you work on this @Bvr4 .

Would you like to do the extention on this, this would be to add an optional 0-n join with users aswell?
Also a assign_user_to_client too?

@Bvr4
Copy link
Contributor

Bvr4 commented Oct 14, 2024

Yes, with pleasure

@peterdudfield
Copy link
Contributor Author

Yes, with pleasure

Thank you. Its probably worth doing user_site_groups too as an optional 0-n join with client, as well as an assign function. I think this would then cover all cases

@Bvr4
Copy link
Contributor

Bvr4 commented Oct 14, 2024

Just to be sure, a client can be related with multiple users. Can a user be related with more than one client ?

@peterdudfield
Copy link
Contributor Author

Just to be sure, a client can be related with multiple users. Can a user be related with more than one client ?

Possibly, like OCF users, but perhaps could we could start with a user can only be part of one client, and then we can add to it, if we need it

@peterdudfield
Copy link
Contributor Author

Thanks @Bvr4 for making an issue, perhaps Ill code this one, if thats ok with you?

@Bvr4
Copy link
Contributor

Bvr4 commented Oct 14, 2024

Yes if you prefer

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

No branches or pull requests

2 participants