openclimatefix / pv-site-datamodel

Datamodel for PV sites
MIT License
2 stars 9 forks source link

Client table #148

Closed peterdudfield closed 1 month ago

peterdudfield commented 3 months ago

Detailed Description

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

Context

Possible Implementation

Bvr4 commented 2 months ago

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 commented 2 months ago

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

Yea, create abd edit function would be great

Bvr4 commented 2 months ago

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 commented 2 months ago

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

peterdudfield commented 2 months ago

It would be great to have a few functions

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

Bvr4 commented 2 months ago

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 commented 2 months ago

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

peterdudfield commented 1 month ago

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 commented 1 month ago

Yes, with pleasure

peterdudfield commented 1 month ago

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 commented 1 month ago

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

peterdudfield commented 1 month ago

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 commented 1 month ago

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

Bvr4 commented 1 month ago

Yes if you prefer