From c3411e90e87712c625e5303b15351770e80cd865 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 11 May 2015 18:43:03 +0300 Subject: server/db_op/DBO_block_chain__commit: factor out _authored_by_statement --- src/server/db_op.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/server') diff --git a/src/server/db_op.py b/src/server/db_op.py index 3b526029..b81bc288 100644 --- a/src/server/db_op.py +++ b/src/server/db_op.py @@ -254,15 +254,15 @@ class DBO_block_chain__commit(DB_op): self.l_id = l_id # create commit-[:__Authored-by]->__User link if possible - if None == ctx or None == ctx.user_name: - return - - q_arr = ['merge (n:%s {user_name: \'%s\'})' % (neo4j_schema.META_LABEL__USER, ctx.user_name), - 'with n', - 'match (m:%s)' % (neo4j_schema.META_LABEL__VC_HEAD), # FIXME: specify commit-label index - 'create (m)-[r:`%s`]->(n)' % (neo4j_schema.META_LABEL__VC_COMMIT_AUTHOR), - ] - self.add_statement(q_arr) + if None != ctx and None != ctx.user_name: + self.add_statement(self._authored_by_statement(ctx.user_name)) + + def _authored_by_statement(self, user_name): + return ['merge (n:%s {user_name: \'%s\'})' % (neo4j_schema.META_LABEL__USER, user_name), + 'with n', + 'match (m:%s)' % (neo4j_schema.META_LABEL__VC_HEAD), # FIXME: specify commit-label index + 'create (m)-[r:`%s`]->(n)' % (neo4j_schema.META_LABEL__VC_COMMIT_AUTHOR), + ] def process_result_set(self): """ -- cgit v1.3.1