-
Notifications
You must be signed in to change notification settings - Fork 3
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
Umar/4903 external resources false broken #2249
Conversation
I'm still confused about the business logic around the backup_url. Do we have a process yet for setting backup_url? When do we use the backup_url, if ever? |
No, we do not have any process yet. @pdpinch If there is no plan to add a process for backup URL, I'll drop it. Currently, it's serving no purpose. |
I think the intention of |
Thanks for the reminder Paul. We decided that we weren't ready to do any automated failover to back_url. Without that, I don't think it makes sense to include the backup_url in the calculation of whether or not the link is broken. We could remove it altogether, but one of our next issues in this epic is to work on "when publishing a course, submit external links to the Internet Archive" at which point it may be convenient to have a field to store the internet archive URL on, even if there is no automated failover. |
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.
Looks good to me!
What are the relevant tickets?
closes https://github.com/mitodl/hq/issues/4903
Description (What does it do?)
Fixes the false
is_broken
flag in case ofIgnored HTTP status codes
. And adds the functionality to updateis_broken
flag on each check rather waiting to be set manually.How can this be tested?
check-broken-external-urls
. Task is set to repeat every week. Frequency can be modified by changingCHECK_EXTERNAL_RESOURCE_STATUS_FREQUENCY
in main/settings.pyAdditional Testing
To manually test the functionality locally with a batch of urls
docker-compose exec web ./manage.py shell
from external_resources.tasks import check_external_resources
from websites.models import WebsiteContent
from websites.constants import CONTENT_TYPE_EXTERNAL_RESOURCE
external_resources = list(WebsiteContent.objects.filter(type=CONTENT_TYPE_EXTERNAL_RESOURCE).values_list("id", flat=True))
len(external_resources)
andexternal_resources = external_resources[:1]
check_external_resources(external_resources)
resources = WebsiteContent.objects.filter(id__in=external_resources).select_related("external_resource_state")
resource = next(resources.iterator())
str(resource.external_resource_state.last_checked)
resource.metadata['is_broken']
resource.metadata['is_broken'] = not resource.metadata['is_broken']
resource.save()
last_checked
and flag again of the updated resource.resource = WebsiteContent.objects.get(id=resource.id)
print(str(resource.external_resource_state.last_checked), resource.metadata['is_broken'])
To manually execute task in celery
docker-compose exec web ./manage.py shell
from external_resources.tasks import check_external_resources_for_breakages
results = check_external_resources_for_breakages.apply()
** This might produce large number of urls to check and may take some time to complete.