Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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',
        ), )
Exemplo n.º 3
0
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},
        ), )
Exemplo n.º 4
0
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',
        ),
    )
Exemplo n.º 5
0
def sync_related_orders_to_es(instance):
    """Sync related orders."""
    transaction.on_commit(
        lambda: sync_related_objects_async(instance, 'orders'),
    )
Exemplo n.º 6
0
def related_contact_sync_search(instance):
    """Sync related Company Contacts."""
    transaction.on_commit(
        lambda: sync_related_objects_async(instance, 'contacts'), )
Exemplo n.º 7
0
def sync_related_interactions_to_es(instance):
    """Sync related interactions."""
    transaction.on_commit(
        lambda: sync_related_objects_async(instance, 'interactions'), )
Exemplo n.º 8
0
def company_subsidiaries_sync_search(instance):
    """Sync company subsidiaries to the OpenSearch."""
    transaction.on_commit(
        lambda: sync_related_objects_async(instance, 'subsidiaries'), )