PrayTeam / scriptured-prayer

GNU Affero General Public License v3.0
1 stars 0 forks source link

Add Genre to UserCards #38

Closed kenancasey closed 5 months ago

kenancasey commented 5 months ago

Each prayer/usercard needs to have a genre field with one of the following values:

@follindown and I realized we need this and didn't have it today.

Soyokaze-42 commented 5 months ago

Is this independent of the category? I have been assuming that all of the prayers in a category would fall into the same genre when we've talked about it.

kenancasey commented 5 months ago

At the moment, all the prayers in a deck are the same genre but that may not always be the case. The genre is a meta-category, i.e., all Names of God are Praise but not all Praise are Names of God. Having this genre property will help us compose a set of cards with the ideal mixture.

I think it would also be useful to show the user this meta-type on each prayer as an icon.

Do you see a problem with adding this?

Soyokaze-42 commented 5 months ago

It is poor form to add information into the database that we already have and adds unnecessary administration on the card maintainers. Not that it is a whole lot of either of those.

Are we planning features like having cards in a category outside that category's normal genre or using the genre as part of the algorithm that selects the daily deck? How are we going to use it to compose a set of cards with the ideal mixture?

The icon is great, but doesn't require extra fields in the database.

kenancasey commented 5 months ago

Yes, @follindown wants to use genres to compose the daily deck so easy access to that field is needed.

I see how including genre is less normalized, but I think the convenience may be worth it so we can select cards and modify the UI using it. Also, it gives us the flexibility to decouple category and genre in the future such that we can have a custom category (e.g. Estes Prayers) that contains multiple genres.

If we restrict a category to a particular genre and fully normalize the schema, then we need a 1-many table that connects them. And we need to join that table to the usercards every time we return user cards to have easy access to it. The frontend should not maintain that relationship.

Instead of doing that, I propose we add genre to the usercards even though it's always (currently) determined by the category.

Soyokaze-42 commented 5 months ago

There are a few things technically here that matter. The Categories are not in a table, they are a list of options on the Cards so we avoid a join for every Card or User card that needs the category. Also, the Card is where we are storing information like this, not the UserCard.

If we need to implement Custom Categories, the way we store this changes. This is the first I've heard of this feature. I've heard of custom Cards. Neither of those are part of the MVP, though.

I've been thinking about this today, too. Custom Cards may be in a category where the category will not determine the genre. It depends on the Categories and whether we want to bind the two together, though.

I agree the backend should be responsible for the state of the objects. Instead of adding a field to the UserCard or Card, I can add a lookup table in the serializer for the API for now without making too many assumptions about the features beyond the MVP. That will get you a genre field in the usercard API and you will not have to map category to genre in the frontend. Will that meet your needs?

kenancasey commented 5 months ago

That would probably work. How hard would it be to add a new "list of options" on the Cards for genre equivalent to how the category is implemented? Is that what you're proposing in the serializer lookup table idea?

I agree the custom categories and cards are a v2 thing, not MVP. However, Follin's idea for how to generate the ideal daily prayer deck does use genre as a primary criterion so having it easily accessible seems necessary (and wise). I'll make a care describing that feature today and maybe that will help communicate the need better.

What are the downsides of adding genre in same way category is structured?

Soyokaze-42 commented 5 months ago

It is not hard at all to add this as an option like the category on the Card model, which is different from what I'm proposing. This is a small part of an unwritten feature that may be done a few different ways and depends on the bigger feature.

If you, as a developer, want to get the genre out of the API so you don't have to use the category to choose your component, putting that logic in the serializer is fine and keeps us from making changes to the schema for part of a feature.

If a user wants to have a specific ratio of different genres in the daily prayer so that the daily prayer feels well-rounded, then we would need to put it on the Card model in support of the feature.

If we are doing this as part of a user (or admin) customization feature, we would need to figure out what customizations we want for categories and genres and will probably have to add a table or two, but don't have to based on what we want to be able to change in the admin interface and users to be able to add in the UI. If we want users to add custom of either, the current approach is cannot work and switching will require some database migrations that I've never done before. Maybe they will be fine, maybe they will be a pain.

We limited the scope of the MVP so that we wouldn't have to figure this sort of thing out. We need to be working out a simple algorithm for the daily prayer so we can ship the product, not the ideal one that will take a lot of extra time to make it perfect.

It would be great to write the feature first as the problem we are trying to solve. This is ambiguous enough I'm not sure what you're actually working on. The daily prayer algorithm for selecting cards based on user options?

kenancasey commented 5 months ago

I definitely want access to the genre from the API. It seems wise to me to add that field to the Card in the schema so that it will be there for both backend usage(deck generation, #42 ) and frontend usage (UI customization, i.e., an icon or other visual distinction for each genre).

Does this clarify the ambiguity? I can write up some more features if that would help.

Soyokaze-42 commented 5 months ago

Nope. These are the decisions we need to make: 1) Are we coupling the genre to the component type in React? 2) Do we want to manage (add/remove/edit) genres from the website? 3) Do we want to manage (add/remove/edit) categories from the website? 4) Do users need to add their own Categories (the alternative I can think of is to have one or a set of custom categories)? 5) Do users need to add their own genres? 6) Are there any other bits of information we will need to store for each category or genre?

It seems to me like we will tie the genre to react components, so no one should add genres from the website. We probably do want to add categories from the website. At least, I don't want to have to make code changes if we are ever planning on adding a category. I kinda don't want users to add categories, but we could leave this open for a future feature if we want to add categories from the website.

@follindown 2 - 5 are mostly Product Owner kinds of questions if you would like to weigh in :)

follindown commented 5 months ago

I think I might need an interpreter if I am to weigh in. What I would like is for users to be able to create their own categories (deck names) for a deck. For me, I would make a deck of Sick, a deck of Cancer, a deck of Missionaries, a deck of Grieving, etc. In making the cards for these decks, I would like people to be able to choose from some premade templates that fall under the 4 genres: Praise, Thanks, Request, Confession so they don't start with a blank card (which can be intimidating). Of course this is all for some future version as I am not expecting this in the MVP. I think the 4 genres should cover everything and so I see no need for a user to create their own genre. It would be super amazing if the template allows for a Bible verse (such as Praise) that the user could just type in the verse reference and the verse be automagically pulled into the card.

Soyokaze-42 commented 5 months ago

@follindown This is just the minimum for what we are building. We are limiting options (or increasing future work) by what we are building, so knowing where we are going helps even though these features are not in the MVP.

Also, I added the bible verse to the cards automatically when viewing the card, so that feature is working!