Beispiel #1
0
def perform_update(entity, entity_id):
    instances = ES_MODEL_MAP[entity].objects.language("all").filter(id=entity_id)
    graph = dependency.build_graph(instances[0], "update")
    if len(graph) > 1:
        bulk_indexer = search.BulkIndexer()
        bulk_indexer.index_data(graph)
    else:
        for node in graph:
            update_node(node)
    def test_instance_exist_from_graph(self):
        # It can be any language version, the foreign key are not translated, why would they?
        organization = Organization.objects.language("en").get(id="3d62d9ea-0600-4f29-8ce6-f7720fd49aa3")
        graph = dependency.build_graph(organization, "update", memory=set())

        for node in graph:
            entity, entity_id, action = node

            instances = consts.ES_MODEL_MAP[entity].objects.language("all").filter(id=entity_id)
            self.assertTrue(instances)
    def test_delete_action(self):
        organization = Organization.objects.language("en").get(id="3d62d9ea-0600-4f29-8ce6-f7720fd49aa3")
        graph = dependency.build_graph(organization, "delete", memory=set())
        memory = set(graph)

        for membership in organization.memberships.all():
            node = ("memberships", membership.id, "delete")
            self.assertTrue(node in memory)

            if membership.post_id:
                post = ("posts", membership.post_id, "delete")
                self.assertTrue(post in memory)
    def test_instance_exist_in_graph(self):
        organization = Organization.objects.language("en").get(id="3d62d9ea-0600-4f29-8ce6-f7720fd49aa3")
        graph = dependency.build_graph(organization, "update", memory=set())
        memory = set(graph)

        # Just a sample of what is in the the graph is good enough
        for membership in organization.memberships.all():
            node = ("memberships", membership.id, "update")
            self.assertTrue(node in memory)

            person = ("persons", membership.person_id, "update")

            self.assertTrue(person in memory)
            if membership.post_id:
                post = ("posts", membership.post_id, "update")
                self.assertTrue(post in memory)
Beispiel #5
0
def perform_update(instance):
    graph = dependency.build_graph(instance, "update")
    for node in graph:
        update_node(node)
Beispiel #6
0
def perform_update(entity, entity_id):
    instances = ES_MODEL_MAP[entity].objects.language("all").filter(id=entity_id)
    graph = dependency.build_graph(instances[0], "update")
    for node in graph:
        update_node(node)