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

AO3-3471 Filter works per language on language_works_path #4659

Merged
merged 9 commits into from
Dec 4, 2023

Conversation

ceithir
Copy link
Contributor

@ceithir ceithir commented Nov 12, 2023

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-3471

Purpose

Filter per language using ElasticSearch; same general behavior as filtering using a tag

Testing Instructions

Go to /languages/en/works, /languages/de/works, /languages/fr/works, etc.
Check the works shown are indeed in the selected language

Note: These routes are currently disabled on staging and production, and I'm not exactly sure how. nginx configuration?

Credit

Ceithir (he/him)

@brianjaustin
Copy link
Member

Summarising conversation from elsewhere: we do hardcode 404 the path for efficiency reasons. In particular

@works = @language.works.recent.visible.limit(ArchiveConfig.NUMBER_OF_ITEMS_VISIBLE_IN_DASHBOARD)
is not super great. For now, let's have show redirect to the /language/:short/works path (we'll need to check admin edits work as normal though).

@weeklies
Copy link
Contributor

@brianjaustin Is this ready to merge or action is still needed?

@ceithir
Copy link
Contributor Author

ceithir commented Nov 16, 2023

we'll need to check admin edits work as normal though

Updated it to return to the index /languages, since that was already what the create route was doing.

@brianjaustin
Copy link
Member

brianjaustin commented Nov 16, 2023

@weeklies you're right, I put the wrong label. Thanks for the poke! I'll try to do another pass this evening (EST) but for now I changed to Coder Has Actioned Review

Edit: @ceithir it looks like there are some failing tests related to the change, would you mind taking a look?

Comment on lines -512 to +516
resources :languages do
resources :languages, except: [:show] do
resources :works
resources :admin_posts
end
get "/languages/:id", to: redirect("/languages/%{id}/works", status: 302)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be more obvious that this route belongs to languages if we use the member block like

Suggested change
resources :languages do
resources :languages, except: [:show] do
resources :works
resources :admin_posts
end
get "/languages/:id", to: redirect("/languages/%{id}/works", status: 302)
resources :languages, except: [:show] do
resources :works
resources :admin_posts
member do
get :show, to: redirect("/languages/%{id}/works", status: 302)
end
end

Copy link
Contributor Author

@ceithir ceithir Nov 17, 2023

Choose a reason for hiding this comment

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

Doesn't appear to work. Or more exactly, it works too well, changing all get routes on /languages to a redirect.

I would say the get "/languages/:id", to:is good enough as is? It's consistent with official documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Oh no, definitely don't want that! I'm definitely good with your version over a version that breaks other things 😂

This reverts commit 3af690d.
@sarken sarken merged commit 18dd650 into otwcode:master Dec 4, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants