diff --git a/DirectReport/browserview/dashboard/routes.py b/DirectReport/browserview/dashboard/routes.py index ee5db4b9..7ee46931 100644 --- a/DirectReport/browserview/dashboard/routes.py +++ b/DirectReport/browserview/dashboard/routes.py @@ -37,7 +37,7 @@ def dashboard_reports_saved(): :return: Rendered HTML template for the list page. """ - results = requests.get('http://127.0.0.1:5000/api/reports/list') + results = requests.get('/api/reports/list') return render_template('list.html', title='List', data=results) @@ -65,37 +65,17 @@ def dashboard_reports_update(): commits_last_ninety = client.get_commits_in_last_ninety_days( current_user.github_username, current_user.github_repo, h_token ) - # get_pull_requests_count = client.get_pull_requests_count( - # current_user.github_username, current_user.github_repo, h_token - # ) - # get_pull_requests_count_sixty = client.get_pull_requests_count_sixty_days( - # current_user.github_username, current_user.github_repo, h_token - # ) + get_pull_requests_count = client.get_pull_requests_count( + current_user.github_username, current_user.github_repo, h_token + ) + get_pull_requests_count_sixty = client.get_pull_requests_count_sixty_days( + current_user.github_username, current_user.github_repo, h_token + ) repo_data = [] for repo in user_repos: repo_data.append(repo["name"]) - raw_data = team_summary_from_shortlog(prompt) - print(raw_data) - raw_reponse = raw_data["choices"][0]["message"]["content"] - response_data = json.loads(raw_reponse) - # print(response_data) - # list(raw_data.choices)[0] - # my_openai_obj.to_dict()['message']['content'] - # response_data = json.loads(raw_data) - # response_data = json.dumps(raw_data) - # raw_data = googleAi.get_data_from(prompt) - # begin, end = raw_data.find('{'), raw_data.rfind('}') - # filtered_str = raw_data[begin: end + 1] - # response_data = json.loads(filtered_str) - response_data["broad_categories"] = { - "debug_info": 16, - "code_maintenance": 9, - "documentation": 7, - "test_related": 6, - "nonbreaking_space_handling": 5, - "readme_update": 1, - "syntax_fix": 1, - } + raw_data = team_summary_from_shortlog(prompt)["choices"][0]["message"]["content"] + response_data = json.loads(raw_data) response_data["commit_nums"] = { "15 days": 4, "30 days": (commits_last_month / 10), @@ -104,15 +84,15 @@ def dashboard_reports_update(): "120 days": 10, } response_data["pull_requests"] = { - "30 days": 5, - "60 days": 6, + "30 days": get_pull_requests_count, + "60 days": get_pull_requests_count_sixty, "90 days": 8, "120 days": 10, "150 days": 10, "1 year": 30, } response_data["repos"] = repo_data - ReportBuilder.new(response_data, prompt, current_user.id, "DirectReport") + ReportBuilder.new(response_data, prompt, current_user.id, current_user.github_repo) return response_data, 201 diff --git a/DirectReport/browserview/main/routes.py b/DirectReport/browserview/main/routes.py index 4c880709..3e07f2ef 100644 --- a/DirectReport/browserview/main/routes.py +++ b/DirectReport/browserview/main/routes.py @@ -12,6 +12,7 @@ from DirectReport.browserview.services.prompt_logic import generate_email from DirectReport.datadependencies import appsecrets + client_id = appsecrets.GITHUB_CLIENT_ID client_secret = appsecrets.GITHUB_CLIENT_SECRET @@ -19,11 +20,9 @@ @bp.before_app_request def before_request(): if current_user.is_authenticated: - print("authenticated user") - print(current_user.github_username) - print(current_user.github_repo) + pass else: - print("unauthenticated user") + pass @bp.route('/', methods=['GET', 'POST']) @@ -100,8 +99,8 @@ def ouath2_callback(): data=data2, auth=(client_id, client_secret), ) - json_Data = json.loads(response2.content) - user_info = json_Data["user"] + json_data = json.loads(response2.content) + user_info = json_data["user"] user_model = UserModel() user_model.update_github_username(current_user.email, user_info["login"]) return render_template('team/teamreport.html', title='Team', data=[]) diff --git a/DirectReport/browserview/services/prompt_logic.py b/DirectReport/browserview/services/prompt_logic.py index c237a50a..e6f4c8b2 100644 --- a/DirectReport/browserview/services/prompt_logic.py +++ b/DirectReport/browserview/services/prompt_logic.py @@ -19,6 +19,6 @@ def team_summary_from_shortlog(data): prompt = prompts.GENERATE_SUMMARY_PROMPT_PREIX + data message = [{"role": "user", "content": prompt}] response = openai.ChatCompletion.create( - model="gpt-4", messages=message, temperature=0, max_tokens=1000, frequency_penalty=0.0 + model="gpt-4", messages=message, temperature=0.1, max_tokens=1000, frequency_penalty=0.0 ) return response diff --git a/DirectReport/browserview/static/js/teamreport/teamreport.js b/DirectReport/browserview/static/js/teamreport/teamreport.js index 57b39ed3..99987519 100644 --- a/DirectReport/browserview/static/js/teamreport/teamreport.js +++ b/DirectReport/browserview/static/js/teamreport/teamreport.js @@ -128,10 +128,10 @@ class TeamReport extends React.Component { strategy: 'fixed' }); document.getElementById('popover-repo-left-purple').classList.toggle("hidden"); - document.getElementById('popover-repo-TitleContent').innerHTML = "Repos" + "(" + repos.length + ")"; + document.getElementById('popover-repo-TitleContent').innerHTML = "Repos" + "(" + this.state.repos.length + ")"; const content = document.getElementById('popover-repo-Content'); var list_element = document.createElement("ul") - repos.map((repo) => { + this.state.repos.map((repo) => { var li = document.createElement("li"); var repoURL = repo["url_repo"].substring(28, repo['url'].length).replace("/", "?repo_url=") li.innerHTML = '' + repo["name"] + '' @@ -146,13 +146,14 @@ class TeamReport extends React.Component { }; render() { + return (