Beispiel #1
0
def connect_nodes(id1, label1, id2, label2):
    node1 = graph.find_one(label1, 'id', id1)
    node1.__primarylabel__ = label1
    node1.__primarykey__ = 'id'

    node2 = graph.find_one(label2, 'id', id2)
    node2.__primarylabel__ = label2
    node2.__primarykey__ = 'id'

    graph.merge(Relationship(node1, 'RELATED_TO', node2))
Beispiel #2
0
    def give_feedback(self, primary_label, node_id, feedback):
        feedback_options = [
            'LIKE',
            'DISLIKE',
            'EASY',
            'HARD',
            'HELPFUL',
            'UNHELPFUL',
            'RELEVANT',
            'IRRELEVANT'
        ]

        if feedback not in feedback_options:
            raise ValueError
        else:
            user = self.find()
            node = graph.find_one(primary_label, 'id', node_id)
            graph.merge(Relationship(user, feedback, node, timestamp=timestamp(), date=date()))
Beispiel #3
0
 def view_fact(self, fact_id):
     user = self.find()
     fact = graph.find_one('Fact', 'id', fact_id)
     graph.merge(Relationship(user, 'VIEWED', fact, timestamp=timestamp(), date=date()))
Beispiel #4
0
 def answer_question(self, question_id, answer):
     user = self.find()
     question = graph.find_one('Question', 'id', question_id)
     graph.merge(Relationship(user, 'ANSWERED', question, timestamp=timestamp(), date=date(), answer=answer))
Beispiel #5
0
    def answer_incorrect(self, question_id):
        user = self.find()
        question = graph.find_one('Question', 'id', question_id)

        graph.merge(Relationship(user, 'ANSWERED_INCORRECTLY', question, timestamp=timestamp(), date=date()))
Beispiel #6
0
 def view_question(self, question_id):
     user = self.find()
     question = graph.find_one('Question', 'id', question_id)
     graph.merge(Relationship(user, 'VIEWED', question, timestamp=timestamp(), date=date()))
Beispiel #7
0
 def find(self):
     user = graph.find_one("User", "username", self.username)
     return user