def test_sync_related_objects_syncs_using_celery(setup_es): """Test that related objects can be synced to Elasticsearch using Celery.""" simpleton = SimpleModel.objects.create() relation_1 = RelatedModel.objects.create(simpleton=simpleton) relation_2 = RelatedModel.objects.create(simpleton=simpleton) unrelated_obj = RelatedModel.objects.create() sync_related_objects_async(simpleton, 'relatedmodel_set') setup_es.indices.refresh() assert doc_exists(setup_es, RelatedModelSearchApp, relation_1.pk) assert doc_exists(setup_es, RelatedModelSearchApp, relation_2.pk) assert not doc_exists(setup_es, RelatedModelSearchApp, unrelated_obj.pk)
def related_investor_profiles_sync_es(instance): """Sync related Company investor profiles to Elasticsearch.""" transaction.on_commit( lambda: sync_related_objects_async( instance, 'investor_profiles', ), )
def related_investor_profiles_sync_es(instance): """Sync related Company investor profiles to Elasticsearch.""" transaction.on_commit( lambda: sync_related_objects_async( instance, 'investor_profiles', related_obj_filter={'profile_type_id': ProfileType.large.value.id}, ), )
def related_large_capital_opportunity_sync_search(instance): """Sync related large capital opportunity Promoters to OpenSearch.""" transaction.on_commit( lambda: sync_related_objects_async( instance, 'opportunities', ), )
def sync_related_orders_to_es(instance): """Sync related orders.""" transaction.on_commit( lambda: sync_related_objects_async(instance, 'orders'), )
def related_contact_sync_search(instance): """Sync related Company Contacts.""" transaction.on_commit( lambda: sync_related_objects_async(instance, 'contacts'), )
def sync_related_interactions_to_es(instance): """Sync related interactions.""" transaction.on_commit( lambda: sync_related_objects_async(instance, 'interactions'), )
def company_subsidiaries_sync_search(instance): """Sync company subsidiaries to the OpenSearch.""" transaction.on_commit( lambda: sync_related_objects_async(instance, 'subsidiaries'), )