hackforla / peopledepot

A project to setup a datastore for people and projects at HackforLA. The link below takes you to the code documentation
https://hackforla.github.io/peopledepot/
GNU General Public License v2.0
5 stars 24 forks source link

Rename `sponsor_partner` to `affiliate` #272

Open fyliu opened 3 months ago

fyliu commented 3 months ago

Overview

We should rename the sponsor_partner table to something like affiliate. And the project_sponsor_partner_xref table to affiliation or similar. This would simplify and clarify the ideas behind these tables.

Also more clear would be converting the project_sponsor_partner_xref.is_sponsor field to type. See discussion below.

Action Items

ERD, spreadsheet, code changes for each of these

Resources/Instructions

Proposed Changes

What the changes give us

Mostly simpler naming for these concepts.

Clearer code when working with the relationship and model.

Example to create a project-affiliate relation

Affiliation.objects.create(project="PeopleDepot", affiliate="Code for America", type="partner")

The current way would look like this

ProjectSponsorPartnerXref.objects.create(project="PeopleDepot", sponsor_partner="Code for America", is_sponsor=False)

_Originally posted by @fyliu in https://github.com/hackforla/peopledepot/pull/270#discussion_r1529113443_

Neecolaa commented 3 months ago
fyliu commented 3 months ago

Sorry I thought posted this that day but I didn't click submit.

The consistent table naming convention sounds good. What if we kept the table_a_table_b_xref as the table name so it's consistent within the database, but changed the model name to Affiliation so that the coding side looks more like English? I believe django models allows specifying a different table name.

Seems like a good idea to set up the association with the org table so we don't have to do it later.

I know it was decided that it's going to be an either or for the project sponsor or partner. But I wonder about the likelihood that it will become something like the org where they can be both. Maybe we need to create a decision record or at least a statement so we're confident this is going to be stable.

I think enums or choices are just short strings. Or maybe that's one of several way to do it but it's the one I can remember. If it's set to 1 char long, then there's that many possible values we can later use. Django translates from sponsor and partner to s and p for our case. We set up the mapping ourselves in the code and the db sees the short strings.

You're right. I realized while testing the PR that the affiliate table needs a uniqueness constraint on the (project_id, sponsor_partner_id) pair. I'm making it part of that issue.

fyliu commented 3 months ago

Updates and actions needed

From comment above:

From the meeting:

fyliu commented 3 months ago

I forgot to bring up the enum during the meeting. It's part of #65 so I'll comment there.

fyliu commented 2 months ago

Cleaning things up a bit here. I made some of the changes part of #65 since that's being worked on right now. The only change remaining here is what the title says.

I just realized I still haven't confirmed the boolean to enum change but it's already being coded. Will have to do that with @Neecolaa at the next meeting to figure out what's best. We can undo the code change if it's not a good direction.

fyliu commented 2 months ago

Here's a comparison of them.

  1. boolean (database boolean)

    • great space usage in database
    • limited to 2 values
    • field has to be called either is_sponsor or is_partner and infer the other based on the boolean value
  2. enum (database varchar)

    • uses less space if it's just 1 or 2 chars long or an int
    • supports 2 values for this case
    • can add more values but it has to be done in code, not db
    • field can be called affiliate_type and printed out as string like my_affiliate.affiliate_type.label == "Sponsor"
    • more clear what the value is
      • in db, affiliate_type can be "sponsor"/"partner", or "s"/"p" if 1-char long, or 1/2 if int (but not clear what the numbers represent, which may be okay since the code knows what it is)
      • in code, my_affiliate.affiliate_type == AffiliateType.SPONSOR
Neecolaa commented 2 months ago

After a discussion with Bonnie at the People Depot meeting, we've decided to add the boolean is_partner to project_affiliate_xref.

A partner is an entity that's doing ongoing work with us on the project. A sponsor is an entity who has provided funds or an in-kind donation.

fyliu commented 1 month ago

Unassigning @freaky4wrld since the coding is done. We just need to change the ERD and spreadsheet for the rest of this issue.