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

Profile Not deleting Bug #3526

Merged
merged 21 commits into from
Apr 27, 2023
Merged

Profile Not deleting Bug #3526

merged 21 commits into from
Apr 27, 2023

Conversation

heintayzar-hm
Copy link
Contributor

@heintayzar-hm heintayzar-hm commented Apr 3, 2023

Resolves #3428

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Workaround

In this Pr, I did the following:

When partners update their profile to an empty value, we will also change it into an "N/A" value(as said in the issue).

When the organization updates its profile to an empty value, we will also change it into an "N/A" value(as said in the issue).

How Has This Been Tested?

In this pr, I test the above functionalities with empty values.

@heintayzar-hm heintayzar-hm changed the title Profile error Profile Not deleting Bug Apr 3, 2023
Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

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

Hey @heintayzar-hm thanks for the PR! I think there should be a way to solve this that doesn't involve putting sentinel strings into the database.

@@ -90,7 +90,7 @@ def profile_params
:enable_individual_requests,
:enable_quantity_based_requests,
documents: []
).select { |_, v| v.present? }
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There was a reason this had to happen before... there was some error that was happening. I don't remember why. 😢

Copy link
Contributor Author

@heintayzar-hm heintayzar-hm Apr 3, 2023

Choose a reason for hiding this comment

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

@dorner , Yeah when I removed that I actually got the error from: #3446

reason that I removed

So the thing here is we check with v.present?. So if there is no value, we are not getting any values from params and not updating and causing this bug.

possible error that you metioned

As for the error that you talked I think it is this one(but I am not very sure):
#3446

if we don't include v.present it is updating files(previously) and getting the error.

I don't know whether I keep the current change or (I can compare the params data and database profile data and then update but this is the current way the only thing that changed is the place we filter things). Please let me know about this one, thank you/

Copy link
Collaborator

@dorner dorner Apr 4, 2023

Choose a reason for hiding this comment

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

Maybe what we can do is instead of checking if the value is present, we check if the key is present in the parameters. That should allow us to save blank values. If that still doesn't work, maybe we handle file uploads separately.

@@ -106,7 +106,7 @@ class Profile < Base
]

def has_no_social_media?
website.blank? && twitter.blank? && facebook.blank? && instagram.blank?
(website.blank? || website == "N/A") && (twitter.blank? || twitter == "N/A") && (facebook.blank? || facebook == "N/A") && (instagram.blank? || instagram == "N/A")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't be forced to use "N/A" when an empty string also indicates that there is no value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will work on that

@heintayzar-hm
Copy link
Contributor Author

heintayzar-hm commented Apr 7, 2023

Hi, it is done. But for showing "N/A" on the profile. I have done it without storing the string in the database but it is affecting other test cases. So I didn't push on this branch.
This is the PR for Updating "N/A" #3532

@dorner
Copy link
Collaborator

dorner commented Apr 14, 2023

@heintayzar-hm I'm confused about how these 2 PRs are related. It seems like both of them fix the same problem, but this one is "incomplete" because it does it by using "N/A", which we said we didn't want to use?

Can we combine these two into a single solution?

@heintayzar-hm
Copy link
Contributor Author

@dorner ok, the reason I divided two prs is in this pr #3532, the changes that I made is affecting other test cases as I changed model getter methods. in this #3532, so I am making sure to include in this pr or not, by your final message, so should I discard the #3532 and did not include "N/A" part?

@dorner
Copy link
Collaborator

dorner commented Apr 18, 2023

@heintayzar-hm I'm not sure I fully understand your question. All I'm really looking for is something that fixes this issue without the additional baggage of an "N/A" sentinel value. If you have a solution for that, then it should be part of a single PR rather than split into two.

@heintayzar-hm
Copy link
Contributor Author

@dorner , it is working and please review again this pr, previous there is a misunderstanding in my end , I am sorry.

But Make sure to reset the database and seed it back cause there might be previous update,

if there is a problem, please let me know 😄😄

@dorner
Copy link
Collaborator

dorner commented Apr 19, 2023

@heintayzar-hm sorry, I'm still confused. The current PR is still setting values to "N/A" instead of blanks.

@heintayzar-hm
Copy link
Contributor Author

Just to be sure, what you want is not setting anything, inside the input fields, not even the value "N/A". (The current pr does not store anything inside the database, I really thought you don't want to only add "N/A", in the database), So if it is tell me, because I think our communication was off 😐😐.

@dorner
Copy link
Collaborator

dorner commented Apr 21, 2023

Correct. When you save a blank field, it should set it to a blank string and that's what should show up on the front-end.

@heintayzar-hm
Copy link
Contributor Author

In these changes, I removed the N/A showing in the frontend. @dorner

end

it "does not store N/A in the database" do
expect(partner.profile.website).to be_nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, is there something that deliberately changes the value "N/A" to nil? If this test passes, I'm not sure why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, It was because I forgot to add reload, it should be partner.profile.reload.website as I a use put request in before block. The caching is causing the problem. I will update with the changes.

@heintayzar-hm
Copy link
Contributor Author

Hi, I finished the testing part, but if you look at my latest commits(latest fours commits), I found that the schema.rb file is updating differently on my side(since I updated to ubuntu 23.04), SO it is changing automatically, in case it will mess up others code, I change it back to previous one.

@dorner
Copy link
Collaborator

dorner commented Apr 27, 2023

@heintayzar-hm this looks good!

@dorner dorner merged commit 39fdaa7 into rubyforgood:main Apr 27, 2023
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

Successfully merging this pull request may close these issues.

[BUG] Partner profile -- fields are not saving if blanked
2 participants