-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
This PR will trigger a patch release when merged. |
src/support/utils.js
Outdated
} finally { | ||
clearTimeout(id); | ||
} | ||
return null; |
There was a problem hiding this comment.
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
src/support/utils.js
Outdated
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; | ||
} | ||
}; |
There was a problem hiding this comment.
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
.
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); |
There was a problem hiding this comment.
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
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.