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

Enforce unique Rules (Old Urls) #62

Closed
wants to merge 1 commit into from

Conversation

aniaw
Copy link

@aniaw aniaw commented May 28, 2021

We assume that duplicate is a redirect rule with the same oldUrl unless this rule RedirectRuleType is set to Regex.

Old pattern New pattern Content Id Redirect Rule Type ... Created on ...
/en/alloy-plan /en/new-alloy-plan -- ExactMatch -- 28-05-2021 11:07:55 --
/en/alloy-plan /en/new-alloy-plan -- ExactMatch -- 27-05-2021 11:07:55 treat as a duplicate
/en/alloy-plan /en/new-alloy -- ExactMatch -- 26-05-2021 11:07:55 treat as a duplicate
/en/alloy-plan -- 1001 ExactMatch -- 25-05-2021 11:07:55 treat as a duplicate
/en/alloy-plan-123 /en/new-alloy-plan-123 -- ExactMatch -- 24-05-2021 11:07:55
/en/alloy-plan-123 /en/* -- Regex -- 23-05-2021 11:07:55 don't treat as a duplicate

Update behavior

  • During importing and adding redirect rules remove duplicate.
  • When adding duplicate: first add a new redirect rule then remove duplicates if exist.

New feature

  • Remove duplicates button - will remove all duplicates

image

@aniaw aniaw requested review from tomaszmadeyski and m-jedynak May 28, 2021 09:17
@aniaw aniaw linked an issue May 28, 2021 that may be closed by this pull request
@tomaszmadeyski tomaszmadeyski linked an issue May 28, 2021 that may be closed by this pull request
}
catch
{
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel that at least what we should do here is to log error through ILogger - I know errors are ignored in every other method (ie Delete, ClearAll) but maybe we should fix that? What do you think @m-jedynak
(Even better solution is to return errror message to end user)

Delete(duplicate.Id.ExternalId);
}
}
return duplicates;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this method returns IQueryable<RedirectRule> (which I'm not 100% sure is required, since it is not used anywhere) I think to be on safe side we should check for null here so the last line:
return duplicates ?? Enumerable.Empty<RedirectRule>().AsQueryable();
so we do not hit NullReferenceException by accident

: _redirectRuleRepository.Delete(id);
bool deletedSuccessfully;

if (id == _clearAllGuid) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not fluent with EpiServer store concept but I wonder if this is possible to have separate methods in controller (I believe it needs to be supported by JS side of EpiServer store): Delete(GuidId), ClearAll() and RemoveAllDuplicates() ?

@Fifok Fifok closed this Sep 8, 2023
@tomaszmadeyski tomaszmadeyski deleted the issue/61-enforce-unique-rules-old-urls branch January 23, 2024 08:48
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.

Enforce unique Rules (Old Urls)
3 participants