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

Fix for instagram links #2849

Merged
merged 12 commits into from
Dec 21, 2018
Merged

Conversation

albarnaz
Copy link
Contributor

@albarnaz albarnaz commented Oct 8, 2018

Issue: #1760

Problem

There is no suggestion in the Instagram empty field in enterprise profile setup menu. Some users copy-paste the full URL on their page. That doesn't work because what is expected is only their Instagram user pseudo.

image

FIX

Add a suggestion/model in the empty field that guides the user so that he enter the Instagram info at the expected format (as it is done for Twitter for instance).

Add migration to fix the wrong links already inputted, from "http://instagram.com/myUser" to "@myUser"

image

Copy link
Contributor

@luisramos0 luisramos0 left a comment

Choose a reason for hiding this comment

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

welcome to OFN @albarnaz
Thanks for your PR!
EDIT: actually I should say Obrigado ;-)

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

Great work on the placeholders and the migration. I still think it would be good to sanitise the user input and extract the handle if the user pastes the URL. That can be done in a separate pull request though.

class UpdateInstagramData < ActiveRecord::Migration
def change
enterprises = Enterprise.where("instagram like ?", "%instagram.com%")
enterprises.each do |e|
Copy link
Contributor

Choose a reason for hiding this comment

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

We should rather use find_each here IMO. This can potentially be a large list of enterprises.

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 agree with it. I will make this change.

@sauloperez
Copy link
Contributor

Welcome aboard @albarnaz !

If you have any questions feel free to ask on the dev channel of our Slack team.

@sigmundpetersen
Copy link
Contributor

Conflicts. Rebase needed? @albarnaz

@daniellemoorhead
Copy link
Contributor

Can whoever stages this do a rebase beforehand perhaps? Not sure if you're still active on here @albarnaz?

@albarnaz
Copy link
Contributor Author

@daniellemoorhead I already made a rebase, but I`m not understanding why it failed

@sobrinho
Copy link

git merge master
git rebase
git push --force

This should do the job

@sobrinho
Copy link

Or even git pull --rebase remote master where remote is openfoodfoundation remote (not your fork).

@luisramos0 luisramos0 added the pr-staged-fr staging.coopcircuits.fr label Oct 30, 2018
@luisramos0
Copy link
Contributor

staged https://staging.openfoodfrance.org

@luisramos0 luisramos0 removed the pr-staged-fr staging.coopcircuits.fr label Nov 6, 2018
@luisramos0
Copy link
Contributor

what we agreed with @RachL and @Matt-Yorkley here is that we want to test the migration.
To do that we need to:
1 - before we stage to UK, have a look at staging UK data and make sure there are some entries with "broken data": instangram.com in the instagram field
2 - stage (which includes the data migration)
3 - verify on the app the instagram.com part is gone from the entries identified on the step 1

I'll can do this but probably next week only.

@mkllnk
Copy link
Member

mkllnk commented Nov 8, 2018

Staged on https://staging.openfoodnetwork.org.au/.

@mkllnk mkllnk added the pr-staged-au staging.openfoodnetwork.org.au label Nov 8, 2018
@RachL
Copy link
Contributor

RachL commented Nov 8, 2018

@mkllnk do you know which data were broken before? (see Luis' post above)

@sstead
Copy link

sstead commented Nov 8, 2018

@maikel I've just had a look and from what I can see, now that the PR is staged it's correctly turning https://www.instagram.com/bravefoods/ into @bravefoods . However as Rachel said, should we check also that existing twitter links in the longhand format are getting fixed? There's very little data on staging, so I cant be sure that any of the profiles were previously in the longhand. Perhaps we create some profile with longhand links and then restage the PR? Or another idea?

@mkllnk
Copy link
Member

mkllnk commented Nov 8, 2018

Okay, Sally and I are trying out this new feature of the Australian staging server. When master code is on staging, the database is not reset. It's used as new baseline. We can use that here:

  1. Stage master.
  2. Create test data we need.
  3. Stage pull request.
  4. Observer effect of migrations / fixes etc.

These Instagram links are probably a good example of test data we don't need to specify in the code as developers. @sauloperez Would you agree?

@sstead
Copy link

sstead commented Nov 9, 2018

Testing Notes
We have a problem...
In order for an instagram link to work the Social Settings must be in the format "happyfarm". Not @happyfarm or https://www.instagram.com/happyfarm or www.instagram.com/happyfarm or /happyfarm

#2859 has been merged, and now the form will convert any new http or www. instagram links into @happyfarm format. This format leads to badges on profiles that are broken. Also, after this PR, now if a profile has their instagram link in the correct format "happyfarm", they'll get an error message when they try to save anything in their Enterprise Settings.
image

I've tested this PR and it's doing what it intends to do - any pre-existing instagram links in the http or www format are converted into @happyfarm links. However, links must be in happyfarm format, not @happyfarm format to work.

So what do we need to do?

  • 2859 should have converted all new links to the plain "happyfarm" format, not "@happyfarm". Can we redo this?
  • 2859 should only give an error message if the Instagram field contains something that cannot be converted to the correct "happyfarm" format. In theory we should be able to convert any kind of link into the correct 'happyfarm' link- including http, www, @happyfarm, or /happyfarm
  • This PR should convert any pre-existing incorrect links (http, www. @happyfarm or /happyfarm) into the correct "happyfarm" format
  • This PR - The prompt in the form should be as below:
    image

Testing notes (nothing not described above)
https://docs.google.com/document/d/1TkmhGczL8t78UnH2VvspQorI1ysp3BjUfsRelzYIETk/edit#

@sstead
Copy link

sstead commented Nov 9, 2018

@mkllnk has reversed #2859 .
I have updated the issue description on #1760 so that it is more clear. Back to you @albarnaz

@mkllnk mkllnk removed the pr-staged-au staging.openfoodnetwork.org.au label Nov 12, 2018
@daniellemoorhead
Copy link
Contributor

Hey @albarnaz 👋
How are you doing with this? Any thoughts on how to move it forward? Have you got some time to finish the work so we can get it reviewed and tested and hopefully merged?

This time of year is a busy one, so totally understand if time got away from you. Let us know if you're able to proceed with this or if we should close it for now and let someone else pick up where you left off 😄

@albarnaz
Copy link
Contributor Author

Hi @daniellemoorhead
I'm going to work on this, I'm sorry I stayed away for a while

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

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

The code looks good. This is ready for testing again.

I ran the migration against the Australian and French production data. It does improve the data, but there are more unhandled cases. This is the conversion on French data:

https://www.instagram.com/conciergerie_de_quartier/ => conciergerie_de_quartier
https://www.instagram.com/conciergerie_de_quartier/ => conciergerie_de_quartier
https://www.instagram.com/geoffrey_martin_74 => geoffrey_martin_74
https://www.instagram.com/clac_conserverie/ => clac_conserverie
https://www.instagram.com/paradisesuperfoods/ => paradisesuperfoods
https://www.instagram.com/ => www.instagram.com
https://www.instagram.com/paradisesuperfoods/ => paradisesuperfoods
https://www.instagram.com/la_panetiere_des_hameaux/ => la_panetiere_des_hameaux
https://www.instagram.com/la_panetiere_des_hameaux/ => la_panetiere_des_hameaux
https://instagram.com/https%3A%2F%2Fwww.instagram.com%2Forangesbio%2F%3Fhl%3Des?fbclid=IwAR35hFjCShjbsS9dL4E914o8OGoPwep_0_m0F0wmulmmHmE4PRlYr04KsZc => https%3A%2F%2Fwww.instagram.com%2Forangesbio%2F%3Fhl%3Des?fbclid=IwAR35hFjCShjbsS9dL4E914o8OGoPwep_0_m0F0wmulmmHmE4PRlYr04KsZc

We still need proper validation for this field.

The commit history contains a few detours now and should be squashed.

@RachL
Copy link
Contributor

RachL commented Dec 20, 2018

Deploying on UK staging

@RachL RachL self-assigned this Dec 20, 2018
@RachL RachL added the pr-staged-uk staging.openfoodnetwork.org.uk label Dec 20, 2018
@RachL
Copy link
Contributor

RachL commented Dec 20, 2018

Alright, didn't forgot front office this time :) As I understand migration has been tested, right @mkllnk ? But indeed we don't have a validation on this field. But in the meantime, new user have now a correct placeholder, which should prevent errors for them.

https://docs.google.com/document/d/1ArkpTlOG94yKE8eucDs1RP476XKxBrg6EowF-KV2ubw/edit#

So I'm moving this to ready to go, and will open another issue for the validation part.

@RachL RachL removed the pr-staged-uk staging.openfoodnetwork.org.uk label Dec 20, 2018
@sauloperez
Copy link
Contributor

@mkllnk do you still want these commits to be squashed? Let's wait for him to ack before merging it.

@albarnaz
Copy link
Contributor Author

@sauloperez I will squash the commits in just one.

@mkllnk
Copy link
Member

mkllnk commented Dec 21, 2018

Yes, we can squash it through Github as well, by selecting it on the merge button.

@mkllnk mkllnk removed the blocked label Dec 21, 2018
@mkllnk mkllnk merged commit 5d51571 into openfoodfoundation:master Dec 21, 2018
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.

10 participants