Add Django site, Docker packaging, and beta/prod Gitea deploys.
Unignore site/ (was blocked by mkdocs /site rule), add compose/Docker/uv tooling, and split deploys so push to main goes to beta while prod stays manual.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils import timezone
|
||||
|
||||
from messaging.models import Message
|
||||
from messaging.tasks import send_campaign_message
|
||||
from social.models import SocialPost
|
||||
from social.tasks import publish_social_post
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = (
|
||||
"Enqueue due scheduled campaign messages and social posts. "
|
||||
"Optional when the task backend supports run_after defer; useful as a safety net."
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
now = timezone.now()
|
||||
enqueued = 0
|
||||
|
||||
for message in Message.objects.filter(
|
||||
status=Message.Status.SCHEDULED,
|
||||
scheduled_for__lte=now,
|
||||
).iterator():
|
||||
message.status = Message.Status.QUEUED
|
||||
message.save(update_fields=["status", "updated_at"])
|
||||
send_campaign_message.enqueue(message_id=str(message.pk))
|
||||
enqueued += 1
|
||||
|
||||
for post in SocialPost.objects.filter(
|
||||
status=SocialPost.Status.SCHEDULED,
|
||||
scheduled_for__lte=now,
|
||||
).iterator():
|
||||
post.status = SocialPost.Status.QUEUED
|
||||
post.save(update_fields=["status", "updated_at"])
|
||||
publish_social_post.enqueue(post_id=str(post.pk))
|
||||
enqueued += 1
|
||||
|
||||
self.stdout.write(self.style.SUCCESS(f"Enqueued {enqueued} due item(s)."))
|
||||
Reference in New Issue
Block a user