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

Move changeset comments feed to resourceful routes #4587

Merged

Conversation

AntonKhorev
Copy link
Collaborator

Changeset comments as nested resources of changesets. That gives path helper names like feed_changeset_changeset_comments_path. At first I tried renaming "changeset_comments" to just "comments", but that didn't work because there's also a feed of all changeset comments and it takes feed_changeset_comments_path.

Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

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

This feels like a "one step forward, one step back" PR to me unfortunately.

There's two parts in moving to resourceful routing, one part is using resources declaration in the routing file, but the other part is trying to have resourceful controller methods i.e. just index/show/new/create/edit/update/destroy , which the resources declarations use by default.

In #2050 (specifically 4b0d56f) I renamed the comments_feed (which is what was used when the code was in changesets_controller) to the index method, since that's what most closely aligns with what this doing i.e. showing a list of objects. So I'd like to keep this as a method named index.

I realise that we still have feed methods elsewhere, but those are targets for refactoring too. There's a difficulty when there are already index methods that do different things (e.g. different lists of objects, or search filters, or other things, so in those cases it can't be as simple as just a respond_to switch) but in those cases I would prefer to see e.g. FooController::index and Foo::FeedController::index or similar, i.e. the method name is still index.

See http://jeromedalbert.com/how-dhh-organizes-his-rails-controllers/ for more info.

@AntonKhorev
Copy link
Collaborator Author

In #2050 (specifically 4b0d56f) I renamed the comments_feed (which is what was used when the code was in changesets_controller) to the index method, since that's what most closely aligns with what this doing i.e. showing a list of objects. So I'd like to keep this as a method named index.

And I do the opposite thing in #4248 because I need the actual index path mapped to the actual index method.

I realise that we still have feed methods elsewhere, but those are targets for refactoring too. There's a difficulty when there are already index methods that do different things (e.g. different lists of objects, or search filters, or other things, so in those cases it can't be as simple as just a respond_to switch) but in those cases I would prefer to see e.g. FooController::index and Foo::FeedController::index or similar, i.e. the method name is still index.

Then that has to be done in all cases where feeds have their own paths.

@gravitystorm
Copy link
Collaborator

Then that has to be done in all cases where feeds have their own paths.

Yes, I think so. Unless there are alternative ideas - I'm willing to discuss options.

@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch from bb1a192 to 58d4a8b Compare March 22, 2024 02:51
@AntonKhorev
Copy link
Collaborator Author

Renamed ChangesetCommentsController to ChangesetCommentsFeedsController and mapped it to a singular comments/feed resource.

@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch from 58d4a8b to 06e6d15 Compare March 25, 2024 23:30
@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch from 06e6d15 to 67680fd Compare May 5, 2024 13:19
@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch 2 times, most recently from b16cb94 to 81907f3 Compare June 12, 2024 13:25
@AntonKhorev AntonKhorev added the changesets Related to the Changesets feature label Jul 3, 2024
@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch 4 times, most recently from 70c5dd0 to f56bbe5 Compare July 16, 2024 13:22
Copy link
Collaborator

@gravitystorm gravitystorm left a comment

Choose a reason for hiding this comment

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

Sorry for the delay in re-reviewing!

@@ -16,7 +16,7 @@ def initialize(user)

if Settings.status != "database_offline"
can [:index, :feed, :show], Changeset
can :index, ChangesetComment
can :show, :changeset_comments_feed
Copy link
Collaborator

Choose a reason for hiding this comment

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

As before, I don't think this is the correct action. This isn't a single object, it's a list of objects, so the method should be index to reflect this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You could have easily argued for the opposite thing, which I'm not going to do because I just want to move feeds out of the way of #4248.

@AntonKhorev AntonKhorev force-pushed the changeset-comment-routes branch from f56bbe5 to 4a38ab5 Compare August 23, 2024 15:25
@gravitystorm
Copy link
Collaborator

I've spent some time considering your point about whether we are :showing a feed, or :indexing a list of changeset comments. In doing so, I've realised that I think the module naming in this PR might be the wrong way round, i.e. Feeds::ChangesetCommentsController vs ChangesetComments::FeedsController.

But with everything related to routes.rb, the only way I can be sure is by messing around and seeing what happens, and now I have an alternative approach ready that I prefer, but I'm not sure what you will think of it.

So what I'm going to do is merge this PR, so that it unblocks your work, and then make my own followup PR for you to review.

@gravitystorm gravitystorm merged commit a948f2b into openstreetmap:master Aug 28, 2024
23 checks passed
@AntonKhorev AntonKhorev deleted the changeset-comment-routes branch August 29, 2024 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changesets Related to the Changesets feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants