def update(user): phab = Phabricator(config.phab_user, config.phab_cert, config.phab_host) pmig = phabdb.phdb(db=config.rtmigrate_db, user=config.rtmigrate_user, passwd=config.rtmigrate_passwd) phabm = phabmacros('', '', '') phabm.con = phab if phabdb.is_bot(user['userphid']): log("%s is a bot no action" % (user['user'])) return True epriority = phabdb.get_user_relations_comments_priority(user['user'], pmig) if epriority and len(epriority[0]) > 0: if epriority[0][0] == ipriority['update_success_comments']: log('Skipping %s as already updated' % (user['user'])) return True if not user['issues']: log("%s has no issues to update" % (user['user'],)) return True for i in user['issues']: comdetails = pmig.sql_x("SELECT comments, \ xcomments \ FROM rt_meta \ WHERE id = %s", (int(i),)) jcom, jxcom = comdetails[0] coms = json.loads(jcom) xcoms = json.loads(jxcom) for key, xi in xcoms.iteritems(): content = xi['content'] if xi["creator"] == user['user']: log("Updating comment %s for %s" % (xi['xctransaction'], user['user'])) phabdb.set_comment_author(xi['xctransaction'], user['userphid']) phabdb.set_comment_content(xi['xctransaction'], xi['content']) current = phabdb.get_user_migration_comment_history(user['user'], pmig) if current: success = ipriority['update_success_comments'] log(phabdb.set_user_relations_comments_priority(success, user['user'], pmig)) else: log('%s user does not exist to update' % (user['user'])) return False pmig.close() log(util.purge_cache()) return True
def update(user): phab = Phabricator(config.phab_user, config.phab_cert, config.phab_host) pmig = phabdb.phdb(host=config.dbhost, db=config.bzmigrate_db, user=config.bzmigrate_user, passwd=config.bzmigrate_passwd) phabm = phabmacros('', '', '') phabm.con = phab if phabdb.is_bot(user['userphid']): log("%s is a bot no action" % (user['user'])) return True epriority = phabdb.get_user_relations_priority(user['user'], pmig) if epriority and len(epriority[0]) > 0: if epriority[0][0] == ipriority['update_success']: log('Skipping %s as already updated' % (user['user'])) return True # 'author': [409, 410, 411, 404, 412], # 'cc': [221, 69, 203, 268, 261, 8], # 'created': 1410276037L, # 'modified': 1410276060L, # 'assigned': [97, 64, 150, 59, 6], # 'userphid': 'PHID-USER-4hsexplytovmqmcb7tq2', # 'user': u'*****@*****.**'} if user['assigned']: for ag in user['assigned']: vlog(phabm.sync_assigned(user['userphid'], ag, bzlib.prepend)) if user['author']: for a in user['author']: vlog(phabm.synced_authored(user['userphid'], a, bzlib.prepend)) if user['cc']: for ccd in user['cc']: vlog(phabdb.add_task_cc_by_ref(user['userphid'], ccd, bzlib.prepend)) current = phabdb.get_user_migration_history(user['user'], pmig) if current: log(phabdb.set_user_relations_priority(ipriority['update_success'], user['user'], pmig)) else: elog('%s user does not exist to update' % (user['user'])) return False pmig.close() return True