Skip to content

Commit

Permalink
[SDESK-7444] - Planning: Migrate planning:flag_expired command to asy…
Browse files Browse the repository at this point in the history
…nc (#2149)

* Changed flag_expired_items to async

* Changed tests to async

* Removed spiked check

* Refactor

* Changed to async in celery task

* Fix failing tests, added docs for get_expired_items for better clarity

* Removed events service.py file

* Suggested fixes

* Removed reference to previous service file

* Added TODO
  • Loading branch information
BrianMwangi21 authored Dec 13, 2024
1 parent 44cf909 commit 744b6a9
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 264 deletions.
17 changes: 10 additions & 7 deletions server/planning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
from superdesk import register_jinja_filter
from .common import get_formatted_address

from .commands import FlagExpiredItems, DeleteMarkedAssignments, ExportScheduledFilters, delete_spiked_items_handler
from .commands import (
flag_expired_items_handler,
DeleteMarkedAssignments,
ExportScheduledFilters,
delete_spiked_items_handler,
)
import planning.commands # noqa
import planning.feeding_services # noqa
import planning.feed_parsers # noqa
Expand Down Expand Up @@ -320,15 +325,13 @@ def init_scheduled_exports_task(app):


@celery.task(soft_time_limit=600)
def flag_expired():
FlagExpiredItems().run()
async def flag_expired():
await flag_expired_items_handler()


@celery.task(soft_time_limit=600)
def delete_spiked():
import asyncio

asyncio.run(delete_spiked_items_handler())
async def delete_spiked():
await delete_spiked_items_handler()


@celery.task(soft_time_limit=600)
Expand Down
2 changes: 1 addition & 1 deletion server/planning/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .flag_expired_items import FlagExpiredItems # noqa
from .flag_expired_items import flag_expired_items_handler # noqa
from .delete_spiked_items import delete_spiked_items_handler # noqa
from .delete_marked_assignments import DeleteMarkedAssignments # noqa
from .export_to_newsroom import ExportToNewsroom # noqa
Expand Down
Loading

0 comments on commit 744b6a9

Please sign in to comment.