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

Uli comm backend #660

Merged
merged 3 commits into from
Jan 21, 2025
Merged

Uli comm backend #660

merged 3 commits into from
Jan 21, 2025

Conversation

maanasb01
Copy link
Collaborator

This is a WIP PR.

The following tasks were covered in this PR:

  • Created the user-contribution context along with the slurs table in the uli_community.
  • In the plugin, completed the login functionality.

CC: @aatmanvaidya

add :appropriated, :boolean, default: false, null: false
add :appropriation_context, :boolean, default: false, null: false
add :meaning, :text
add :category, {:array, :string}
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a way to make it array of enum values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey, I think it is possible, I would need to check but I think it can be done. But my doubt here is that we were letting the user add categories from the UI where we are providing the options in a dropdown. So I was thinking about whether we should keep controlling the user input from the UI itself.

We can maintain this enum in the database and then fetch these categories for options to be provided in the UI. But this might be not the very ideal case given that the categories are going to be mostly unchanged, and also doing this would make the frontend make a request every time the form comes up which could be unnecessary given the mentioned reason.

We can also maintain the categories in 2 places, one in the database and the other in the UI, but we would need to sync them in case there is any change in the categories.

For these reasons, I thought to control the categories from the UI only. Please let me know what your thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

As you correctly said, the categories wont be changed often, so it doesnt justify making an API call for them. We'll maintain the category list in two places - backend and frontend. we'll have to remember to update at both places when changes need to be made.
My reason to insist on using enums for this is that it would be more egregious if as an error we save a unrecognized category value. So defining this as an enum would protect against it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool, so will make it an array of enums them. Will push the changes here.

end

@doc false
def changeset(crowdsourced_slur, attrs) do
Copy link
Contributor

Choose a reason for hiding this comment

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

A tip. There's a few ways to create crowdsouced_slur

  1. Only add the label and none of the other fields
  2. Add label and one or more of the other fields
  3. Add/update values like category, level_of_severity etc for an already existing slur

You might need more than one changeset to capture these possibilities.

Conventionally these functions should be named changeset_*. We can discuss appropriate names later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey, yeah sure I will add more methods to create an entry with different scenarios. This was generated by the Phoenix generator. I was planning to add these on a requirement basis when I integrate the FE and BE.

Regarding this, just want to confirm, when I see the "add slur" form, I see that apart from appropriation_context and "what makes it problematic" fields, all other fields are necessary, so should I only create the changeset regarding these?

@dennyabrain
Copy link
Contributor

@maanasb01 I see that these three stories are getting addressed now :

#651
#653
#646

I have a feeling that #652 would also work but since I cant save my preferences, i am not able to test this.

Regardless, can i link the first three issues to this PR and merge this into dev?

@maanasb01
Copy link
Collaborator Author

Hey Denny, I have just pushed all the changes, including adding the signup redirect on the login page. Regarding those sub-issues, yes they are all resolved now. For issue #652, are you referring to the "Enable Slur Metadata" option? If yes, then it is also resolved. Users can enable both options replacement/show-metadata without any authentication.

One more thing, with the implementation of these new changes, the crowd-sourced slur feature is broken. I will fix it next while working on the slurs functionality, but just letting you know. If you want, I can change it such that the option to "add slur" would only come if the user is logged in, in this PR itself. Otherwise, would make all the changes in the new PR.

Let me know your thoughts!

@dennyabrain
Copy link
Contributor

@maanasb01 All sounds good.
I figured that the "crowdsource slur" would be broken. Since I am only merging this to dev, its fine. Crowdsourcing is its own beast and I want to closely review it in the next PR. So will merge this and then close the linked stories.

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