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 24, 2024
1 parent cb2b321 commit f54d6a3
Show file tree
Hide file tree
Showing 2 changed files with 24 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
20 changes: 20 additions & 0 deletions src/openforms/contrib/open_producten/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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 12 in src/openforms/contrib/open_producten/tasks.py

View check run for this annotation

Codecov / codecov/patch

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

Added line #L12 was not covered by tests

out = io.StringIO()

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L14 was not covered by tests

call_command("import_prices", stdout=out)

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L16 was not covered by tests

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

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L18 was not covered by tests

return out.getvalue()

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

View check run for this annotation

Codecov / codecov/patch

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

Added line #L20 was not covered by tests

0 comments on commit f54d6a3

Please sign in to comment.