Esempio n. 1
0
def _add_feedback_query(feedback_: Feedback):
    g = Traversel()

    # create SecurityEvent obj with only url as property, which is enough
    # to find the existing node to add feedback
    security_event = SecurityEvent(url=feedback_.feedback_url)

    g.has_node(security_event).and_(
        Traversel.anonymous().add_unique_node(feedback_))
    if feedback_.feedback_type is FeedBackType.NEGATIVE:
        g.weakens(feedback_, security_event)
    else:
        g.reinforces(feedback_, security_event)

    return str(g.next())
Esempio n. 2
0
def _ingest_feedback(payload):
    """Creates Feedback node into the graphdb based on data"""
    # pylint: disable=invalid-name
    g = Traversel()
    # create SecurityEvent obj with only url as property, which is enough
    # to find the existing node to add feedback
    security_event = SecurityEvent(url=payload['url'])
    feedback_ = Feedback(author=payload['author'],
                         feedback_type=FeedBackType[payload['feedback_type']],
                         comments=payload['comments'])
    g.has_node(security_event).add_unique_node(feedback_)
    if feedback_.feedback_type is FeedBackType.NEGATIVE:
        g.weakens(feedback_, security_event)
    else:
        g.reinforces(feedback_, security_event)
    return execute_query(g.next())