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 get_user_histories(verified): histories = [] pmig = phabdb.phdb(db=config.bzmigrate_db, user=config.bzmigrate_user, passwd=config.bzmigrate_passwd) for v in verified: vlog(str(v)) saved_history = phabdb.get_user_migration_comment_history(v[1], pmig) if not saved_history: log('%s verified email has no saved history' % (v[1],)) continue log('%s is being processed' % (v[1],)) history = {} history['user'] = v[1] history['userphid'] = v[0] history['issues'] = saved_history[0] history['created'] = saved_history[1] history['modified'] = saved_history[2] histories.append(history) pmig.close() return [util.translate_json_dict_items(d) for d in histories]