Skip to content

Commit

Permalink
project
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswebb09 committed Jan 6, 2024
1 parent f9c8a79 commit b3e1584
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 50 deletions.
44 changes: 12 additions & 32 deletions DirectReport/browserview/dashboard/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Check warning on line 40 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L40

Added line #L40 was not covered by tests
return render_template('list.html', title='List', data=results)


Expand Down Expand Up @@ -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(

Check warning on line 68 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L68

Added line #L68 was not covered by tests
current_user.github_username, current_user.github_repo, h_token
)
get_pull_requests_count_sixty = client.get_pull_requests_count_sixty_days(

Check warning on line 71 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L71

Added line #L71 was not covered by tests
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)

Check warning on line 78 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L77-L78

Added lines #L77 - L78 were not covered by tests
response_data["commit_nums"] = {
"15 days": 4,
"30 days": (commits_last_month / 10),
Expand All @@ -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)

Check warning on line 95 in DirectReport/browserview/dashboard/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/dashboard/routes.py#L95

Added line #L95 was not covered by tests
return response_data, 201


Expand Down
11 changes: 5 additions & 6 deletions DirectReport/browserview/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
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


@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

Check warning on line 23 in DirectReport/browserview/main/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/main/routes.py#L23

Added line #L23 was not covered by tests
else:
print("unauthenticated user")
pass

Check warning on line 25 in DirectReport/browserview/main/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/main/routes.py#L25

Added line #L25 was not covered by tests


@bp.route('/', methods=['GET', 'POST'])
Expand Down Expand Up @@ -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"]

Check warning on line 103 in DirectReport/browserview/main/routes.py

View check run for this annotation

Codecov / codecov/patch

DirectReport/browserview/main/routes.py#L102-L103

Added lines #L102 - L103 were not covered by tests
user_model = UserModel()
user_model.update_github_username(current_user.email, user_info["login"])
return render_template('team/teamreport.html', title='Team', data=[])
Expand Down
2 changes: 1 addition & 1 deletion DirectReport/browserview/services/prompt_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions DirectReport/browserview/static/js/teamreport/teamreport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<span>' + repo["name"] + '</span>'
Expand All @@ -146,13 +146,14 @@ class TeamReport extends React.Component {
};

render() {

return (
<div>
<h1 id="h1content" className="self-center text-center text-2xl text-blue-800 text-center font-bold font-mono pt-10 pb-2 mb-8 pt-8 mx-30 px-20">Generate Team Report From Metadata</h1>
<h1 id="h1content" className="self-center text-center text-2xl text-blue-800 text-center font-bold font-mono pt-5 mb-8 pt-8 mx-30 px-20">Generate Team Report From Metadata</h1>
{repoPopoverUI()}
{spinnerUI()}
<div id="topRow" className="grid grid-cols-3 gap-10 rounded-3xl mx-20 mt-6">
{EditSummaryElem(this.state.commits, this.state.repos, this.state, this.state.repoSelected, this.openRepoPopover)}
{EditSummaryElem({"repos": this.state.repos, "commits": this.state.commits}, this.state, this.openRepoPopover)}
{SummarySection(this.state.teamData, this.state.reportData)}
{TeamSection(this.state.teamData, this.closePopover)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ const ShowHighlights = (report) => {


const ShowTeamList = (team) => {
console.log(team);
return (
<div class="items-center pt-1 select-none">
{team !== undefined ?
team.map(team_member =>
<button class="bg-blue-600 py-1 px-2 pb-1 pt-1 mr-0.5 my-0.5 no-underline rounded-full text-white font-sans border-2 border-gray text-xs btn-primary hover:text-white hover:bg-indigo-700 focus:outline-none active:shadow-none" onClick={(event) => openPopover(event, team_member)}>{team_member.name}
<button class="bg-blue-600 py-1 px-2 pb-1 pt-1 mr-0.5 my-0.5 no-underline rounded-full text-white font-sans border-2 border-gray text-xs btn-primary hover:text-white hover:bg-indigo-700 focus:outline-none active:shadow-none" onClick={(event) => openPopover(event, team_member)}>{
team_member.name}
</button>
) : null
}
</div>
)
}

const openPopover = (e: ChangeEvent<HTMLInputElement>, teammember) => {
const openPopover = (e: ChangeEvent<HTMLInputElement>, team_member) => {
let element = e.target;
while ("BUTTON" !== element.nodeName) {
element = element.parentNode;
Expand All @@ -63,9 +65,15 @@ const openPopover = (e: ChangeEvent<HTMLInputElement>, teammember) => {
resize: true
});
document.getElementById('popover-id-left-purple').classList.toggle("hidden");
document.getElementById('popoverTitleContent').innerHTML = teammember.name
document.getElementById('popoverContent').innerHTML = teammember.accomplishments;
document.getElementById('popoverCommits').innerHTML = "Commits: " + teammember.commits;
document.getElementById('popoverTitleContent').innerHTML = team_member.name
var a = document.createElement('a');
a.setAttribute('href',"https://www.github.com/" + team_member.github_username);
a.innerHTML = "Github Profile"
var p = document.createElement("p");
p.innerHTML = team_member.accomplishments + "<br/> <br/>";
p.appendChild(a);
document.getElementById('popoverContent').appendChild(p);
document.getElementById('popoverCommits').innerHTML = "Commits: " + team_member.commits;
}

const repoPopoverUI = () => {
Expand Down Expand Up @@ -135,7 +143,7 @@ const GithubButtonElement = (repos, openRepoPopover, state) => {
<div className="self-center mb-1 mt-1">
<div className="mx-0 min-w-full flex flex-col items-center">
{repos.length > 0 && (
<button className="bg-white hover:bg-slate-100 self-center text-blue-600 font-mono tracking-wide shadow-[1.5px_2px_1.0px_0.5px_rgba(0,0,0,0.48)] hover:white hover:text-blue-500 hover:border-gray-200 text-md font-bold py-3 px-12 rounded-3xl mt-2 mb-3" onClick={(e) => openRepoPopover(repos, state)} type="button">
<button className="bg-white hover:bg-slate-100 self-center text-blue-600 font-mono tracking-wide shadow-[1.5px_2px_1.0px_0.5px_rgba(0,0,0,0.48)] hover:white hover:text-blue-500 hover:border-gray-200 text-md font-bold py-3 px-12 rounded-3xl mt-2 mb-3" onClick={(e) => openRepoPopover({repos}, {state})} type="button">
<svg xmlns="http://www.w3.org/2000/svg" className="h-7 w-6 inline-block ml-10" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
</svg>
Expand All @@ -150,6 +158,7 @@ const GithubButtonElement = (repos, openRepoPopover, state) => {
}

const GithubEntryElement = (commits) => {
console.log(commits);
return (
<div>
{commits.length > 0 && (
Expand Down Expand Up @@ -216,7 +225,11 @@ const spinnerUI = () => {
)
}

const EditSummaryElem = (commits, repos, state, openRepoPopover) => {
const EditSummaryElem = (props, state, openRepoPopover) => {
let repos = props['repos'];
let commits = props['commits'];
console.log(repos);
console.log({repos});
return (
<div className="lg:col-span-1 sm:col-span-3 justify-center" id="edit_summary_div">
<div className="pb-6 pt-2 bg-blue-600 rounded-3xl px-6 shadow-[1.0px_1.0px_2.0px_1.0px_rgba(0,0,0,0.58)]">
Expand Down

0 comments on commit b3e1584

Please sign in to comment.