예제 #1
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()))
예제 #2
0
    def edit_fact(self, fact_id, title, tags, text):
        user = self.find()
        fact = Node(
            'Fact',
            id = fact_id,
            title = title,
            text = text,
            timestamp = timestamp(),
            date = date()
        )

        rel = Relationship(user, 'EDITED', fact)
        graph.merge(rel, 'Fact', 'id')

        tags = [x.strip() for x in tags.lower().split(',')]
        for name in set(tags):
            tag = Node('Tag', name=name)
            graph.merge(tag, 'Tag', 'name')
            rel = Relationship(tag, 'TAGGED', fact)
            graph.merge(rel)
예제 #3
0
    def add_fact(self, title, tags, text):
        user = self.find()
        fact = Node(
            'Fact',
            id = str(uuid.uuid4()),
            title = title,
            text = text,
            timestamp = timestamp(),
            date = date()
        )

        rel = Relationship(user, 'PUBLISHED', fact)
        graph.create(rel)

        tags = [x.strip() for x in tags.lower().split(',')]
        for name in set(tags):
            tag = Node('Tag', name=name)
            graph.merge(tag, 'Tag', 'name')
            rel = Relationship(tag, 'TAGGED', fact)
            graph.merge(rel)
예제 #4
0
    def edit_question(self, question_id, title, tags, text, answer):
        user = self.find()
        question = Node(
            'Question',
            id = question_id,
            title = title,
            text = text,
            answer = answer,
            timestamp = timestamp(),
            date = date()
        )

        rel = Relationship(user, 'EDITED', question)
        graph.merge(rel, 'Question', 'id')

        tags = [x.strip() for x in tags.lower().split(',')]
        for name in set(tags):
            tag = Node('Tag', name=name)
            graph.merge(tag, 'Tag', 'name')
            rel = Relationship(tag, 'TAGGED', question)
            graph.merge(rel)
예제 #5
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()))
예제 #6
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))
예제 #7
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()))
예제 #8
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()))