Loading Procfile 0 → 100644 +2 −0 Changes for Procfile: 2 added lines, 0 removed lines. Original line number Diff line number Diff line web: uv run manage.py runserver worker: uv run manage.py rqworker default email_batch --job-class django_tasks_rq.Job No newline at end of file README.md +5 −2 Changes for README.md: 5 added lines, 2 removed lines. Original line number Diff line number Diff line # wybory ## Prerequisites - [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/) instance running ## Run for development - clone the repo - make sure you have [uv](https://docs.astral.sh/uv/) installed - create venv and install dependencies: `uv sync --frozen` - setup environmental variables: `cp sample.env .env` and adjust values as needed - run migrations: `uv run manage.py migrate` - create superuser: `uv run manage.py createsuperuser` - run development server: `uv run manage.py runserver` - run background tasks worker `uv run manage.py rqworker --job-class django_tasks_rq.Job` - run development server and worker `uv run honcho start` mails/tasks.py +6 −1 Changes for mails/tasks.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line from django.tasks import task from django.conf import settings from voters.models import Voter from mails.models import Mail Loading @@ -6,16 +7,20 @@ from mails.models import Mail from django.db import transaction from functools import partial import time @task(queue_name='email_batch') def send_mail_batch(): # batch = Mail.objects.filter(status='PENDING')[:2] ids_to_update = Mail.objects.filter(status='PENDING').values_list('pk', flat=True)[:2] ids_to_update = Mail.objects.filter(status='PENDING').values_list('pk', flat=True)[:settings.EMAIL_BATCH_SIZE] updated_count = Mail.objects.filter(pk__in=ids_to_update).update(status='PROCESSING') if updated_count == 0: return None time.sleep(2) if Mail.objects.filter(status='PENDING').exists(): send_mail_batch.enqueue() Loading pyproject.toml +1 −0 Changes for pyproject.toml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,5 +8,6 @@ dependencies = [ "django-environ>=0.13.0", "django-rq>=4.0.1", "django-tasks-rq>=0.12.0", "honcho>=2.0.0", "redis>=7.3.0", ] uv.lock +14 −0 Changes for uv.lock: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -144,6 +144,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5e/2e/b41d8a1a917d6581fc27a35d05561037b048e47df50f27f8ac9c7e27a710/freezegun-1.5.5-py3-none-any.whl", hash = "sha256:cd557f4a75cf074e84bc374249b9dd491eaeacd61376b9eb3c423282211619d2", size = 19266, upload-time = "2025-08-09T10:39:06.636Z" }, ] [[package]] name = "honcho" version = "2.0.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/65/c8/d860888358bf5c8a6e7d78d1b508b59b0e255afd5655f243b8f65166dafd/honcho-2.0.0.tar.gz", hash = "sha256:af3815c03c634bf67d50f114253ea9fef72ecff26e4fd06b29234789ac5b8b2e", size = 45618, upload-time = "2024-10-06T14:26:53.871Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/48/1c/25631fc359955569e63f5446dbb7022c320edf9846cbe892ee5113433a7e/honcho-2.0.0-py3-none-any.whl", hash = "sha256:56dcd04fc72d362a4befb9303b1a1a812cba5da283526fbc6509be122918ddf3", size = 22093, upload-time = "2024-10-06T14:26:52.181Z" }, ] [[package]] name = "python-dateutil" version = "2.9.0.post0" Loading Loading @@ -239,6 +251,7 @@ dependencies = [ { name = "django-environ" }, { name = "django-rq" }, { name = "django-tasks-rq" }, { name = "honcho" }, { name = "redis" }, ] Loading @@ -248,5 +261,6 @@ requires-dist = [ { name = "django-environ", specifier = ">=0.13.0" }, { name = "django-rq", specifier = ">=4.0.1" }, { name = "django-tasks-rq", specifier = ">=0.12.0" }, { name = "honcho", specifier = ">=2.0.0" }, { name = "redis", specifier = ">=7.3.0" }, ] Loading
Procfile 0 → 100644 +2 −0 Changes for Procfile: 2 added lines, 0 removed lines. Original line number Diff line number Diff line web: uv run manage.py runserver worker: uv run manage.py rqworker default email_batch --job-class django_tasks_rq.Job No newline at end of file
README.md +5 −2 Changes for README.md: 5 added lines, 2 removed lines. Original line number Diff line number Diff line # wybory ## Prerequisites - [Redis](https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/) instance running ## Run for development - clone the repo - make sure you have [uv](https://docs.astral.sh/uv/) installed - create venv and install dependencies: `uv sync --frozen` - setup environmental variables: `cp sample.env .env` and adjust values as needed - run migrations: `uv run manage.py migrate` - create superuser: `uv run manage.py createsuperuser` - run development server: `uv run manage.py runserver` - run background tasks worker `uv run manage.py rqworker --job-class django_tasks_rq.Job` - run development server and worker `uv run honcho start`
mails/tasks.py +6 −1 Changes for mails/tasks.py: 6 added lines, 1 removed line. Original line number Diff line number Diff line from django.tasks import task from django.conf import settings from voters.models import Voter from mails.models import Mail Loading @@ -6,16 +7,20 @@ from mails.models import Mail from django.db import transaction from functools import partial import time @task(queue_name='email_batch') def send_mail_batch(): # batch = Mail.objects.filter(status='PENDING')[:2] ids_to_update = Mail.objects.filter(status='PENDING').values_list('pk', flat=True)[:2] ids_to_update = Mail.objects.filter(status='PENDING').values_list('pk', flat=True)[:settings.EMAIL_BATCH_SIZE] updated_count = Mail.objects.filter(pk__in=ids_to_update).update(status='PROCESSING') if updated_count == 0: return None time.sleep(2) if Mail.objects.filter(status='PENDING').exists(): send_mail_batch.enqueue() Loading
pyproject.toml +1 −0 Changes for pyproject.toml: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -8,5 +8,6 @@ dependencies = [ "django-environ>=0.13.0", "django-rq>=4.0.1", "django-tasks-rq>=0.12.0", "honcho>=2.0.0", "redis>=7.3.0", ]
uv.lock +14 −0 Changes for uv.lock: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -144,6 +144,18 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/5e/2e/b41d8a1a917d6581fc27a35d05561037b048e47df50f27f8ac9c7e27a710/freezegun-1.5.5-py3-none-any.whl", hash = "sha256:cd557f4a75cf074e84bc374249b9dd491eaeacd61376b9eb3c423282211619d2", size = 19266, upload-time = "2025-08-09T10:39:06.636Z" }, ] [[package]] name = "honcho" version = "2.0.0" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/65/c8/d860888358bf5c8a6e7d78d1b508b59b0e255afd5655f243b8f65166dafd/honcho-2.0.0.tar.gz", hash = "sha256:af3815c03c634bf67d50f114253ea9fef72ecff26e4fd06b29234789ac5b8b2e", size = 45618, upload-time = "2024-10-06T14:26:53.871Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/48/1c/25631fc359955569e63f5446dbb7022c320edf9846cbe892ee5113433a7e/honcho-2.0.0-py3-none-any.whl", hash = "sha256:56dcd04fc72d362a4befb9303b1a1a812cba5da283526fbc6509be122918ddf3", size = 22093, upload-time = "2024-10-06T14:26:52.181Z" }, ] [[package]] name = "python-dateutil" version = "2.9.0.post0" Loading Loading @@ -239,6 +251,7 @@ dependencies = [ { name = "django-environ" }, { name = "django-rq" }, { name = "django-tasks-rq" }, { name = "honcho" }, { name = "redis" }, ] Loading @@ -248,5 +261,6 @@ requires-dist = [ { name = "django-environ", specifier = ">=0.13.0" }, { name = "django-rq", specifier = ">=4.0.1" }, { name = "django-tasks-rq", specifier = ">=0.12.0" }, { name = "honcho", specifier = ">=2.0.0" }, { name = "redis", specifier = ">=7.3.0" }, ]