Exemple #1
0
 def delete(self, *args, **kwargs):
     batch = WriteBatch(graph_db)
     node = self.get_node()
     for rel in node.get_relationships():
         batch.delete_relationship(rel)
     batch.delete_node(node)
     super(Campaign, self).delete(*args, **kwargs)
Exemple #2
0
 def set_contacts(self, profiles):
     """
     *profiles* -- registration.models.Userprofile objects.
     """
     me = self.get_node()
     batch = WriteBatch(graph_db)
     for profile in profiles:
         batch.get_or_create_relationship(me, self.contact_relationship,
                                          profile.__node__)
     r = batch.submit()
     logger.warn(r)
Exemple #3
0
 def set_is_client(self, is_client):
     if not is_client:
         self.is_client = False
         self.save()
         return
     batch = WriteBatch(neomodel.core.connection())
     for rel in self.known.all():
         batch.delete(rel)
     batch.set_node_property(self.__node__, 'is_client', True)
     self.get_set_client_lock().acquire()
     try:
         batch.submit()
     finally:
         self.get_set_client_lock().release()
Exemple #4
0
create_business_query = '''
// MERGE ON categories
CREATE (b:Business {id: {business_id}, name: {name}, lat:{latitude}, lon:{longitude},
	stars: {stars}, review_count: {review_count}})
'''

merge_category_query = '''
MATCH (b:Business {id: {business_id}})
MERGE (c:Category {name: {category}})
CREATE UNIQUE (c)<-[:IS_IN]-(b)
'''

print "Beginning business batch"
with open('data/yelp_academic_dataset_business.json', 'r') as f:
    business_batch = WriteBatch(db)
    count = 0
    for b in (json.loads(l) for l in f):
        business_batch.append_cypher(create_business_query, b)
        count += 1
        if count >= 10000:
            business_batch.run()
            business_batch.clear()
            count = 0
    if count > 0:
        business_batch.run()

print "Beginning category batch"
with open('data/yelp_academic_dataset_business.json', 'r') as f:
    category_batch = WriteBatch(db)
    count = 0