Skip to content

Commit

Permalink
[maykinmedia/open-producten#24] Add celery task
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Oct 29, 2024
1 parent 9448af1 commit 709a1d6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/openforms/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@
"task": "openforms.authentication.tasks.update_saml_metadata",
"schedule": crontab(hour=0, minute=0, day_of_week="sunday"),
},
"import-open-producten-prices": {
"task": "openforms.contrib.open_producten.tasks.import_product_type_prices",
"schedule": crontab(hour=0, minute=0, day_of_week="*"),
},
}

RETRY_SUBMISSIONS_TIME_LIMIT = config(
Expand Down
21 changes: 21 additions & 0 deletions src/openforms/contrib/open_producten/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import io
import logging

from django.core.management import call_command

from openforms.celery import app

logger = logging.getLogger(__name__)


@app.task()
def import_product_type_prices():
logger.info("starting import_prices() task")

Check warning on line 13 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/contrib/open_producten/tasks.py#L13

Added line #L13 was not covered by tests

out = io.StringIO()

Check warning on line 15 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/contrib/open_producten/tasks.py#L15

Added line #L15 was not covered by tests

call_command("import_prices", stdout=out)

Check warning on line 17 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/contrib/open_producten/tasks.py#L17

Added line #L17 was not covered by tests

logger.info("finished import_prices() task")

Check warning on line 19 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/contrib/open_producten/tasks.py#L19

Added line #L19 was not covered by tests

return out.getvalue()

Check warning on line 21 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/openforms/contrib/open_producten/tasks.py#L21

Added line #L21 was not covered by tests

0 comments on commit 709a1d6

Please sign in to comment.