Skip to content

Send notifications for events created in bulk #1762

@hmpf

Description

@hmpf

Whenever we use Event.objects.bulk_create we do not send any signals, which means we cannot send any notifications. It is easy to override Event.objects.bulk_create to force it to send signals:

from django.db.models.signals import post_save

…

class EventQuerySet(models.QuerySet):
    def bulk_create(self, objs, **kwargs):
        objs = tuple(objs)
        qs = super().bulk_create(objs, **kwargs)
        for event in objs:
            post_save.send(event.__class__, instance=event, created=True)

 class Event(models.Model):
    …
    objects = EventQuerySet.as_manager()
    …

… but if we do, everybody will get A LOT more notifications. There are mitigations like only sending notifications for some event types, like only open/close/end/reopen via the fallback filter setting, but it needs to be flagged to end users, loudly.

We could also stop using bulk_create and make our own method, freeing bulk_create to be used as was designed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working as expecteddiscussionRequires developer feedback/discussion before implementationnotificationAffects the notification systemnotifications

    Type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions