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

fix: add fixed status to suggestions #634

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

alinarublea
Copy link
Contributor

@alinarublea alinarublea commented Feb 6, 2025

Currently when we new suggestions are created from a new audit run, we delete the old suggestions that don t reappear from the new audit.
We should check if the old ones are fixed, and mark them as such.

@alinarublea alinarublea marked this pull request as draft February 6, 2025 09:38
Copy link

github-actions bot commented Feb 6, 2025

This PR will trigger a patch release when merged.

@alinarublea alinarublea added the bug Something isn't working label Feb 6, 2025
} finally {
clearTimeout(id);
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of returning null we could return { ok: false } to avoid exceptions

Comment on lines 322 to 330
export const isFixedURL = async (backlink) => {
try {
const response = await fetchWithTimeout(backlink.url_to, TIMEOUT);
return response.ok;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
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.

This might not work for other audits than backlinks right now.

Also we could introduce an expectedStatusCode, for broken backlinks it should be 301 and for sitemap the url is fixed when it is 200.

Suggested change
export const isFixedURL = async (backlink) => {
try {
const response = await fetchWithTimeout(backlink.url_to, TIMEOUT);
return response.ok;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
};
export const isFixedURL = async (url, expectedStatusCode = 200) => {
try {
const response = await fetchWithTimeout(url, TIMEOUT);
return response.status === expectedStatusCode;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
};

.map(async (suggestion) => {
const isSuggestionFixed = await isFixed(suggestion);
if (isSuggestionFixed) {
suggestion.setStatus(Suggestion.STATUSES.FiXED);
Copy link
Member

Choose a reason for hiding this comment

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

it would be better to use Suggestion.bulkUpdateStatus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants