mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
17 lines
488 B
Python
17 lines
488 B
Python
|
|
||
|
|
||
|
from celery import shared_task
|
||
|
from .models import SearchResult
|
||
|
|
||
|
|
||
|
@shared_task(autoretry_for=(Exception,), retry_kwargs={'max_retries': 0, 'countdown': 5})
|
||
|
def create_search_result(title, link):
|
||
|
if SearchResult.objects.filter(title=title, link=link).exists():
|
||
|
return ("SearchResult entry already exists")
|
||
|
else:
|
||
|
SearchResult.objects.create(
|
||
|
title=title,
|
||
|
link=link
|
||
|
)
|
||
|
return f"Created new SearchResult entry titled: {title}"
|