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

[Rails] Don't pass orphaned Stories (e.g. no Places or Speakers) to React #956

Open
2 tasks
rudokemper opened this issue Sep 23, 2023 · 9 comments
Open
2 tasks
Assignees
Labels
Hacktoberfest Hacktoberfest 2023 rails

Comments

@rudokemper
Copy link
Member

Currently, it's not possible to create a Story without selecting at least one Place and at least one Speaker.

However, it is possible to delete Places and Speakers, which if done can leave a Story "orphaned" (e.g. it exists but has no Places, or Speakers, or both).

It's fine to keep it this way on the Rails side for now -- we need to think about our data structures more -- but we should handle this on the React side.

What is happening now is that the stories will still show up in StoryList. Only, if there are no Speakers, nothing will show at the top, and (worse) if there are no Places, clicking on the card does nothing.

Let's filter out any stories that have 0 Places or 0 Speakers on the React front end. This also means we should filter out any markers on the map that ONLY have stories that have been filtered out.

Acceptance criteria:

  • If I create a Story, a Place, and a Speaker, and then I delete the Place OR the Speaker (or both), the Story should continue to exist in Rails but it should not be passed to React (e.g. it doesn't show up in StoryList component).
  • If I create a Story, a Place, and a Speaker, and I delete the Speaker, the Story should not be passed to React, and the Place should also not be passed to React (IF is the only Story associated with it; it should continue to appear on the map if it has other Stories with the minimum validation of >1 Place and >1 Speaker).
@rudokemper rudokemper added rails Hacktoberfest Hacktoberfest 2023 labels Sep 23, 2023
@ice1080
Copy link
Contributor

ice1080 commented Oct 4, 2023

I can take this one!

@ice1080
Copy link
Contributor

ice1080 commented Oct 4, 2023

Question on this one, assuming for @rudokemper, I'll be filtering out the orphaned stories from dashboard/stories_controller, but should do the same to api/stories_controller? I'm less familiar with what the api module is used for

@rudokemper
Copy link
Member Author

Great question. That is actually used by a new Terrastories React view at https://github.com/terrastories/explore-terrastories, which we still need to document properly. I think it'd be good to filter it out from there as well.

@ice1080
Copy link
Contributor

ice1080 commented Oct 5, 2023

Thanks for the follow up!
Regarding this issue, I've got the changes locally but wanted to make sure there are no tests around the pages or dashboard controllers (except Manage Community). Is this correct or am I not seeing them?

A related note, here is a potential way to avoid orphaned parents in this situation. Our use case would be slightly more complex since there are two children to check in the parent, but could still work.
https://stackoverflow.com/questions/5866378/delete-orphaned-parent

@rudokemper
Copy link
Member Author

Thank you! I don't believe we have any tests for the pages or controllers. That would be a welcome addition, but I'm also happy to test your work locally for this.

If I'm understanding that article correctly, the suggestion would be to delete any parent if there are no more children left, right? That would not be desirable in our use case; a user might be drafting content and we want to be very intentional about giving them complete control over their actions. Some of our users are not very technical and a piece of content disappearing on them (because it was deleted due to orphanage) could be confusing.

@ice1080
Copy link
Contributor

ice1080 commented Oct 5, 2023

I'm new to rails but not to unit testing, so I'll see if I can put together a couple tests around these.

What you mentioned makes sense in terms of not wanting content to disappear because it's deleted, however wouldn't that pretty much be the case with acceptance 1? If they delete the last speaker or place attached to a story, then that story no longer shows up in the list of stories that can be edited right? So they won't be able to add a speaker/place back? Or did I misinterpret this one?

@rudokemper
Copy link
Member Author

Acceptance criteria #1 means that the story should continue to exist in the db and is accessible for editing or viewing in Rails, but it should no longer show in the StoryList component on React (on the front end, e.g. /home/ route)

@ice1080
Copy link
Contributor

ice1080 commented Oct 5, 2023

Got it! I'll update my work; it might be that both acc 1 and 2 are complete by the work for 2.

@ice1080
Copy link
Contributor

ice1080 commented Oct 6, 2023

This one is ready for review @rudokemper! #971

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hacktoberfest Hacktoberfest 2023 rails
Projects
None yet
Development

No branches or pull requests

2 participants