def team_impact_graph(request): if request.method == 'POST': username = request.values['values'] print(username) dict['name'] = username multiplier, repo = function_with_cache(find_multiplier, [username]) top_contributors = function_with_cache(get_top_contributors, [repo]) cleaned_top_contributors = [] for contributor in top_contributors: if contributor[1] != username: cleaned_top_contributors.append(contributor) top_contributors_list = [] max_val = cleaned_top_contributors[0][0] for element in cleaned_top_contributors: scaled = element[0] / max_val * 50 dict_form = { 'userId': element[1], 'before': scaled, 'after': scaled * multiplier } top_contributors_list.append(dict_form) self_info = [[{'userId': username}]] top_contributors_list = [[top_contributors_list]] dict_form = {'data': top_contributors_list, 'personalData': self_info} return dict_form elif request.method == 'GET': print("yo") return jsonify(dict)
def get_additional_team(username): dict_all = function_with_cache(data_dict, [username]) dict_form = { 'inspiration_coefficient': dict_all['inspiration_coefficient'], 'team_value': dict_all['team_value'] } return dict_form
def get_additional_potential(username): dict_all = function_with_cache(data_dict, [username]) dict_form = { 'java_expertise': dict_all['java_expertise'], 'commitment': dict_all['commitment'] } return dict_form
def find_multiplier(github_id): result = function_with_cache(data_dict, [github_id]) if 'impact_repos' in result.keys() and result['impact_repos']: repo = result['impact_repos'] multiplier = result['impact_rates'] print(repo) return multiplier, repo[0] return 1.5, 'pytorch/pytorch'
def test(): def test_function(first, last): print(first, last) return {'first': first, 'last': last} test_vals = [[0, 1], [1, 3], [0, 1]] for val in test_vals: result = function_with_cache(test_function, val) return jsonify(result)
def potential_number(request): if request.method == 'POST': username = request.values['values'] print(username) dict['name'] = username dict_form = {'number': function_with_cache(get_potential, [username])} return dict_form elif request.method == 'GET': print("yo") return jsonify(dict)
def team_number_additional(request): if request.method == 'POST': username = request.values['values'] print(username) dict['name'] = username dict_form = function_with_cache(get_additional_team, [username]) return dict_form elif request.method == 'GET': print("yo") return jsonify(dict)
def future_graph(request): if request.method == 'POST': username = request.values['values'] print(username) dict['name'] = username past_data, future_data = function_with_cache(predict_future, [username]) dict_form = {'future_data': future_data, 'past_data': past_data} return dict_form elif request.method == 'GET': print("yo") return jsonify(dict)
def get_world(username): dict_all = function_with_cache(data_dict, [username]) return dict_all['world_impact']
def get_potential(username): dict_all = function_with_cache(data_dict, [username]) return dict_all['potential_impact']
def get_team(username): dict_all = function_with_cache(data_dict, [username]) return dict_all['team_impact']
def get_additional_world(username): dict_all = function_with_cache(data_dict, [username]) dict_form = {'repository_impact': dict_all['repository_impact']} return dict_form