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

Avoid using hardcoded localhost in Redirects #380

Merged

Conversation

JakubMastalerz
Copy link
Contributor

@JakubMastalerz JakubMastalerz commented Dec 12, 2023

This PR changes old_url handling in RedirectType to replace hardcoded URL generation with dynamically generated URLs based on wagtail's sites properties.

Additionally:

  • Fixes issue where query would fail if Redirect had no specified target.
  • Introduces general test suite for redirects.

The changes were tested for performance and did not increase the number of queries when querying Redirects.

@JakubMastalerz JakubMastalerz force-pushed the feature/improve-redirect-handling branch 2 times, most recently from 8eeb2ab to f642999 Compare December 12, 2023 16:12
@JakubMastalerz JakubMastalerz marked this pull request as ready for review December 12, 2023 16:31
@JakubMastalerz JakubMastalerz changed the title Draft: Avoid using hardcoded localhost in Redirects Avoid using hardcoded localhost in Redirects Dec 12, 2023
Copy link
Collaborator

@kbayliss kbayliss left a comment

Choose a reason for hiding this comment

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

A great start, though there's some choices that will cause issues that need addressing.

grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
tests/testapp/factories.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
tests/test_redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Show resolved Hide resolved
tests/testapp/factories.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Show resolved Hide resolved
grapple/types/redirects.py Show resolved Hide resolved
@kbayliss kbayliss marked this pull request as draft December 19, 2023 10:21
@JakubMastalerz JakubMastalerz force-pushed the feature/improve-redirect-handling branch from 3356150 to a003b5a Compare December 19, 2023 13:17
@JakubMastalerz JakubMastalerz marked this pull request as ready for review December 19, 2023 14:58
@JakubMastalerz JakubMastalerz force-pushed the feature/improve-redirect-handling branch from 75707b2 to c5feca2 Compare December 19, 2023 15:03
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
tests/test_redirects.py Outdated Show resolved Hide resolved
tests/test_redirects.py Outdated Show resolved Hide resolved
grapple/types/redirects.py Outdated Show resolved Hide resolved
Comment on lines 44 to 45
class Meta:
name = "Redirect"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be moved to just below the fields? I appreciate there isn't a standard way of doing that within this project (sometimes it's above the fields and sometimes it's below), though it's never at the end :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in c2a5365

grapple/types/redirects.py Outdated Show resolved Hide resolved
@kbayliss
Copy link
Collaborator

kbayliss commented Jan 4, 2024

@JakubMastalerz this is looking GREAT! As discussed earlier, can you review the performance of these changes to check we're not adversely affecting performance? In particular, I'm interested in the number of queries being made to ensure we're not causing any N+1 queries.

@kbayliss kbayliss force-pushed the feature/improve-redirect-handling branch from 6950794 to 12fd694 Compare January 5, 2024 15:58
@kbayliss kbayliss merged commit 49c1716 into torchbox:main Jan 5, 2024
13 checks passed
@kbayliss kbayliss deleted the feature/improve-redirect-handling branch January 5, 2024 17:04
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.

None yet

2 participants