Skip to content

run typesense post save actions on transaction commit #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ jobs:
- name: Setup TypeSense
uses: jirevwe/typesense-github-action@v1.0.1
with:
typesense-version: 0.26
typesense-version: 0.26.0
typesense-api-key: sample_key

- name: Run tests
5 changes: 4 additions & 1 deletion django_typesense/signals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.db import transaction
from django.db.models.signals import m2m_changed, post_save, pre_delete
from django.dispatch import receiver

@@ -9,7 +10,9 @@ def post_save_typesense_models(sender, instance, **kwargs):
if not issubclass(sender, TypesenseModelMixin):
return

sender.get_collection(instance, update_fields=kwargs.get('update_fields', [])).update()
transaction.on_commit(
sender.get_collection(instance, update_fields=kwargs.get('update_fields', [])).update
)


@receiver(pre_delete)
Loading