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

Fixed username error #9435

Merged
merged 22 commits into from
Apr 20, 2021
Merged

Fixed username error #9435

merged 22 commits into from
Apr 20, 2021

Conversation

gaurav2699
Copy link
Contributor

@gaurav2699 gaurav2699 commented Apr 3, 2021

Fixes #9421 (<=== Add issue number here)]
Screenshots:
This wiki doesnt have a user associated
Screenshot from 2021-04-07 21-34-06

Screenshot from 2021-04-07 21-34-29
no user exists with uid 4
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@gitpod-io
Copy link

gitpod-io bot commented Apr 3, 2021

@codecov
Copy link

codecov bot commented Apr 3, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@1f32f56). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 1fff1d1 differs from pull request most recent head 160a83d. Consider uploading reports for the commit 160a83d to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9435   +/-   ##
=======================================
  Coverage        ?   81.36%           
=======================================
  Files           ?       98           
  Lines           ?     5930           
  Branches        ?        0           
=======================================
  Hits            ?     4825           
  Misses          ?     1105           
  Partials        ?        0           

Copy link
Member

@pydevsg pydevsg left a comment

Choose a reason for hiding this comment

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

Looks good to me @gaurav2699 🎉
Please add a screenshot of the change before and after you made the changes 😅 .

@pydevsg
Copy link
Member

pydevsg commented Apr 7, 2021

Also, @gaurav2699 next time make sure to use a local branch instead of your main branch to push the changes.

@gaurav2699
Copy link
Contributor Author

Definitely @pydevsg, thanks a lot!

@gaurav2699
Copy link
Contributor Author

@pydevsg I added screenshots. Thanks!

@pydevsg
Copy link
Member

pydevsg commented Apr 7, 2021

Last but not least squash commits when you make so many commits.

@gaurav2699
Copy link
Contributor Author

gaurav2699 commented Apr 7, 2021

sure @pydevsg. I dont know why commits from my previous PR's that got merged are also here. Maybe because I didn't change the branch. I will squash it and make sure I use a different branch next time. Thanks

@codeclimate
Copy link

codeclimate bot commented Apr 8, 2021

Code Climate has analyzed commit 160a83d and detected 0 issues on this pull request.

View more on Code Climate.

Copy link
Collaborator

@Tlazypanda Tlazypanda left a comment

Choose a reason for hiding this comment

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

@gaurav2699 LGTM 🎉 For squashing the commits you may use git rebase -i HEAD~no.of.commits and then set as required.

@cesswairimu
Copy link
Collaborator

cesswairimu commented Apr 8, 2021

Looking good 🎉 ...I think we need to confirm with @jywarren if we want to delete user's nodes once the user is deleted once we get a green light on that we are good to merge here. Thanks all

Copy link
Contributor

@RuthNjeri RuthNjeri left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @gaurav2699, I do agree with Cess, we need confirmation on whether a user's node should be deleted once they are out of the system...I wonder how this would affect nodes with co-authors or nodes that are important in the system...perhaps we should have a system ID for a "user"?? That maybe replaces the node uid when a user is deleted...

@gaurav2699
Copy link
Contributor Author

Yes @RuthNjeri. I also now think its not a good idea to delete the nodes when the user who created the node is deleted because we might lose some important nodes due to this, and there might be nodes with multiple authors which should not be deleted. Having a system ID makes sense, so we can show it as deleted user or something else like Anonymous maybe.

@gaurav2699
Copy link
Contributor Author

Lets see what @jywarren thinks of this and I will make changes according to that.

@jywarren
Copy link
Member

Hi all, i appreciate this conversation so much. Great work identifying the issue which i now see is affecting not only #9417 but also #9527, confirmed that we have some revisions without user records. (44698, 69032 uids in the database).

Agreed that we should not allow this to happen but also THANK YOU for triple checking on the policy of preserving data before approving and merging this. Great call.

I'm not 100% sure either. I think we really almost NEVER delete a user, so it's interesting to me to try to figure out how this happened in the first place.

For one, I see that https://publiclab.org/wiki/revisions/getting-started and https://publiclab.org/wiki/revisions/spectral-workbench-api both show missing authors, and both around 8 years ago. So I wonder if this is no longer a risk; it's not like we've seen any user deletion recently.

With that in mind I think i approve this! I'll check once more and then merge it. Thanks again!!!

@@ -46,10 +46,10 @@ module Frequency
# validates_attachment_content_type :photo_file_name, :content_type => %w(image/jpeg image/jpg image/png)

has_many :images, foreign_key: :uid
has_many :node, foreign_key: 'uid'
has_many :node, foreign_key: 'uid', dependent: :destroy
Copy link
Member

Choose a reason for hiding this comment

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

Confirmed that this will, when the user is destroyed, delete all the nodes and revisions:

https://guides.rubyonrails.org/association_basics.html#why-associations-questionmark

@jywarren jywarren merged commit bd0bc11 into publiclab:main Apr 20, 2021
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* Added translations in users/settings.html.erb

* Fixed pagination issue

* fixed pagination issue

* Fixed pagination in wiki/stale too

* Delete identifier.sqlite

* fixed a minor issue

* Fixed minor issue

* Delete identifier.sqlite

* Added functional test to check pagination

* reduced no of new wikis for test

* reduced 31 to 12

* fixed username error

* fixed username error

Co-authored-by: Cess <[email protected]>
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* Added translations in users/settings.html.erb

* Fixed pagination issue

* fixed pagination issue

* Fixed pagination in wiki/stale too

* Delete identifier.sqlite

* fixed a minor issue

* Fixed minor issue

* Delete identifier.sqlite

* Added functional test to check pagination

* reduced no of new wikis for test

* reduced 31 to 12

* fixed username error

* fixed username error

Co-authored-by: Cess <[email protected]>
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.

ActionView::Template::Error: undefined method `username' for nil:NilClass
6 participants