Skip to content

Commit

Permalink
Merge pull request #56 from chriswebb09/dev-branch
Browse files Browse the repository at this point in the history
update ui for reports
  • Loading branch information
chriswebb09 authored Dec 24, 2023
2 parents d22f513 + 22877cc commit ef1dfb4
Show file tree
Hide file tree
Showing 23 changed files with 310 additions and 152 deletions.
9 changes: 7 additions & 2 deletions DirectReport/browserview/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

import sys
from pathlib import Path
from flask import Flask, request
Expand All @@ -13,7 +15,6 @@
package_root_directory = file.parents[1]
sys.path.append(str(package_root_directory))


client_id = appsecrets.GITHUB_CLIENT_ID
client_secret = appsecrets.GITHUB_CLIENT_SECRET
login_manager = LoginManager()
Expand Down Expand Up @@ -57,12 +58,16 @@ def create_app(config_class=Config):

from DirectReport.browserview.api import bp as api_bp

app.register_blueprint(api_bp)
app.register_blueprint(api_bp, url_prefix='/api')

from DirectReport.browserview.errors import bp as errors_bp

app.register_blueprint(errors_bp)

from DirectReport.browserview.dashboard import bp as dashboard_bp

app.register_blueprint(dashboard_bp, url_prefix='/dashboard')

app.secret_key = appsecrets.SECRET_KEY
login_manager.init_app(app)
app.config.from_object(config_class)
Expand Down
2 changes: 2 additions & 0 deletions DirectReport/browserview/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from flask import Blueprint

bp = Blueprint('api', __name__)
Expand Down
5 changes: 2 additions & 3 deletions DirectReport/browserview/api/auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import sqlalchemy as sa
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
#!/usr/bin/env python3

# from app import db
from flask_httpauth import HTTPBasicAuth, HTTPTokenAuth
from DirectReport.models.user_model import UserModel
from DirectReport.browserview.api.errors import error_response

Expand Down
3 changes: 3 additions & 0 deletions DirectReport/browserview/api/errors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env python3

from werkzeug.http import HTTP_STATUS_CODES
from werkzeug.exceptions import HTTPException

from DirectReport.browserview.api import bp


Expand Down
123 changes: 62 additions & 61 deletions DirectReport/browserview/api/reports.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from flask import render_template, request, json
from flask_login import login_required, current_user

Expand All @@ -9,75 +11,74 @@
from DirectReport.browserview.api import bp


@bp.route("/report", methods=['GET', 'POST'])
@login_required
def report():
prompt = ""
prompt = request.get_json()["prompt"]
client = GithubClient()
# print(prompt)
user_repos = client.get_user_repos("chriswebb09")
repodata = []
for repo in user_repos:
# print(repo)
# print("\n")
repodata.append(repo["name"])
log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement"
googleAi = GoogleAIClient()
response_data = googleAi.get_data_from(prompt).replace("\'", "\"")
response_data = response_data.replace('\n', " ")
data_json = json.loads(response_data)
data_json["broad_categories"] = {
"debug_info": 16,
"code_maintenance": 9,
"documentation": 7,
"test_related": 6,
"nonbreaking_space_handling": 5,
"readme_update": 1,
"syntax_fix": 1,
}
data_json["shortlog"] = client.parse_git_shortlog(log_item)
data_json["repos"] = repodata
ReportBuilder.new(data_json, prompt, current_user.id, "DirectReport")
return data_json, 201

# @bp.route("/report", methods=['GET', 'POST'])
# @login_required
# def report():
# prompt = ""
# prompt = request.get_json()["prompt"]
# client = GithubClient()
# user_repos = client.get_user_repos("chriswebb09")
# repodata = []
# for repo in user_repos:
# repodata.append(repo["name"])
# log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement"
# googleAi = GoogleAIClient()
# response_data = googleAi.get_data_from(prompt).replace("\'", "\"")
# response_data = response_data.replace('\n', " ")
# data_json = json.loads(response_data)
# data_json["broad_categories"] = {
# "debug_info": 16,
# "code_maintenance": 9,
# "documentation": 7,
# "test_related": 6,
# "nonbreaking_space_handling": 5,
# "readme_update": 1,
# "syntax_fix": 1,
# }
# data_json["shortlog"] = client.parse_git_shortlog(log_item)
# data_json["repos"] = repodata
# ReportBuilder.new(data_json, prompt, current_user.id, "DirectReport")
# return data_json, 201

@bp.route("/reports/new", methods=['GET', 'POST'])
@login_required
def team_report():
if request.method == "POST":
json_data = request.get_json()
report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at'])
print(report_model)
return render_template('team/teamreport.html', title='Team Report', data=[])

# @bp.route("/reports/new", methods=['GET', 'POST'])
# @login_required
# def team_report():
# if request.method == "POST":
# json_data = request.get_json()
# report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at'])
# print(report_model)
# return render_template('team/teamreport.html', title='Team Report', data=[])
#

@bp.route("/reports/<uid>", methods=['GET'])
@login_required
def get_report(uid=None):
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
# print(report["report"])
return render_template('team/teamreport.html', title='Team Report', teamData=report["report"])
# @bp.route("/reports/<uid>", methods=['GET'])
# @login_required
# def get_report(uid=None):
# reports = ReportBuilder.get_reports_for_user_id(current_user.id)
# report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
# return render_template('team/teamreport.html', title='Team Report', teamData=report["report"])
#


@bp.route("/reports/list/new", methods=['GET'])
@bp.route("/reports/list", methods=['GET'])
@login_required
def get_list():
print(current_user.id)
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
return reports, 201


@bp.route("/reports", methods=['GET', 'POST'])
@login_required
def list_entries():
"""
Retrieves and renders the list of all entries.
:return: Rendered HTML template for the list page.
"""
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
report_results = []
for report in reports:
report_element = {"report": report}
report_results.append(report_element)
return render_template('list.html', title='List', data=report_results)
#
# @bp.route("/reports", methods=['GET', 'POST'])
# @login_required
# def list_entries():
# """
# Retrieves and renders the list of all entries.
# :return: Rendered HTML template for the list page.
# """
# reports = ReportBuilder.get_reports_for_user_id(current_user.id)
# report_results = []
# for report in reports:
# report_element = {"report": report}
# report_results.append(report_element)
# return render_template('list.html', title='List', data=report_results)
5 changes: 4 additions & 1 deletion DirectReport/browserview/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/env python3

from flask import Blueprint
from DirectReport.browserview.auth import routes

bp = Blueprint('auth', __name__)

from DirectReport.browserview.auth import routes
13 changes: 7 additions & 6 deletions DirectReport/browserview/auth/routes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from flask import render_template, request, redirect, url_for, flash
from flask_login import login_user, login_required, logout_user, current_user
from werkzeug.security import generate_password_hash
Expand Down Expand Up @@ -43,7 +45,7 @@ def login():
if user and user.check_password(password):
login_user(user, remember=remember, force=True)
if current_user.is_authenticated():
return redirect(url_for('auth.account'))
return redirect(url_for('dashboard.dashboard_home'))
else:
print("password no match")
flash("Please check your login details and try again.")
Expand All @@ -52,11 +54,10 @@ def login():
)


#
@bp.route("/account", methods=['GET', 'POST'])
@login_required
def account():
return render_template('account.html', title='Account', name=current_user.username, userid=current_user.id)
# @bp.route("/account", methods=['GET', 'POST'])
# @login_required
# def account():
# return render_template('account.html', title='Account', name=current_user.username, userid=current_user.id)


@bp.route("/account_data", methods=['GET'])
Expand Down
7 changes: 7 additions & 0 deletions DirectReport/browserview/dashboard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python3

from flask import Blueprint

bp = Blueprint('dashboard', __name__)

from DirectReport.browserview.dashboard import routes
91 changes: 91 additions & 0 deletions DirectReport/browserview/dashboard/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env python3

from datetime import datetime, timedelta
import requests
from flask import render_template, session, request, redirect, json
from flask_login import login_user, login_required, logout_user, current_user

from DirectReport.browserview.dashboard import bp
from DirectReport.models.report.report_builder import ReportBuilder
from DirectReport.browserview.services.github import GithubClient
from DirectReport.browserview.services.github import GoogleAIClient
from DirectReport.models.report.report_model import ReportModel
from DirectReport.datadependencies import appsecrets

client_id = appsecrets.GITHUB_CLIENT_ID
client_secret = appsecrets.GITHUB_CLIENT_SECRET


@bp.route("/home", methods=['GET', 'POST'])
@login_required
def dashboard_home():
return render_template('account.html', title='Account', name=current_user.username, userid=current_user.id)


@bp.route("/reports/saved", methods=['GET', 'POST'])
@login_required
def dashboard_reports_saved():
"""
Retrieves and renders the list of all entries.
:return: Rendered HTML template for the list page.
"""

results = requests.get('http://127.0.0.1:5000/api/reports/list')
print(results)
# reports = ReportBuilder.get_reports_for_user_id(current_user.id)
# report_results = []
# for report in reports:
# report_element = {"report": report}
# report_results.append(report_element)
# print(len(report_results))
return render_template('list.html', title='List', data=results)


@bp.route("/reports/new", methods=['GET', 'POST'])
@login_required
def dashboard_reports_new():
if request.method == "POST":
json_data = request.get_json()
report_model = ReportModel(json_data["id"], json_data['summary'], json_data['created_at'])
return render_template('team/teamreport.html', title='Team Report', data=[])


@bp.route("/reports/update", methods=['GET', 'POST'])
@login_required
def dashboard_reports_update():
prompt = ""
prompt = request.get_json()["prompt"]
client = GithubClient()
user_repos = client.get_user_repos("chriswebb09")
repodata = []
for repo in user_repos:
repodata.append(repo["name"])
log_item = "Adrian Prantl (67):\n add mangling testcase\n Debug Info: Represent private discriminators in DWARF.\n Revert \"Debug Info: Represent private discriminators in DWARF.\n Debug Info: Represent private discriminators in DWARF.\n Un-XFAIL and update test.\n Move the logic for ignoring the debug locations for closure setup code into SILGen. NFC-ish.\n Debug Info: Associate a function call with the beginning of the expression.\n Debug Info / SILGen: fix the source location of variable assignments\n typo\n Fix the debug locations of inserted operations in AvailableValueAggregator.\n Don't emit shadow copies for anonymous variables.\n Remove dead API IRGenDebugInfo::setArtificialTrapLocation().\n Use compiler-generated location for func.-sig.-spec. thunks\n whitespace\n Fix the missing inlined-at field of function-level SILDebugScopes.\n Add debug info support for inlined and specialized generic variables.\n Revert Add debug info support for inlined and specialized generic variables.\n Add debug info support for inlined and specialized generic variables.\n Update mangling prefix in Mangling.rst\n Add initial support for debug info for coroutine allocas.\n Temporarily disable failing test case, rdar://problem/43340064\n Add build-script support for the Swift LLDB backwards-compatibility tests.\n Remove accidentally committed debugging code\n Deserialize Swift compatibility version in CompilerInvocation::loadFromSerializedAST()\n SILGen: Preserve function argument debug info for arguments needing alloc_stack\n Use as the filename for SILLocation-less functions to avoid misleading source locatio\nns in backtraces.\n Add a -verify-linetable LLVM option.\n Enable debug info for inlined generics by default. It works now.\n Fix nonasserts compilation\n\nAhmad Alhashemi (5):\n [Parser] Detect nonbreaking space U+00A0 and fixit\n Move non-breaking space handling to lexUnknown\n Add more non-breaking space test cases\n Minor style edits\n Add tests for non-breaking space detect and fix-it\n\nAkshay Shrimali (1):\n Update README.md\n\nAlan Zeino (1):\n Fix typo in code example in libSyntax README\n\nAlbin Sadowski (1):\n Fix syntax highlighting in CHANGELOG (#15107)\n\nAlejandro (3):\n Remove a warning, some doc fixes (#16863)\n [SR-8178] Fix BinaryFloatingPoint.random(in:) open range returning upperBound (#17794)\n [Docs] Fix minor code typo in SILPro..Man..md\n\nAlex Blewitt (5):\n [SR-7032] Fix compare for lhs and rhs\n [SR-7036] Use || instead of && for kind comparison\n [SR-7041] Remove duplicate conditional check\n Remove duplicate verb\n [SR-7043] Remove duplicate if statement"
googleAi = GoogleAIClient()
response_data = googleAi.get_data_from(prompt)
print(response_data)
# ).replace("\'", "\"")
# response_data = response_data.replace('\n', " ")
# print(response_data)
# data_json = json.loads(response_data)
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,
}
response_data["shortlog"] = client.parse_git_shortlog(log_item)
response_data["repos"] = repodata
ReportBuilder.new(response_data, prompt, current_user.id, "DirectReport")
return response_data, 201


@bp.route("/reports/<uid>", methods=['GET'])
@login_required
def dashboard_saved_report(uid=None):
reports = ReportBuilder.get_reports_for_user_id(current_user.id)
report = list(filter(lambda report: report["uuid"] == uid, reports))[0]
return render_template('team/teamreport.html', title='Team Report', teamData=report["report"])
6 changes: 4 additions & 2 deletions DirectReport/browserview/errors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from flask import Blueprint
from DirectReport.browserview.errors import handlers
#!/usr/bin/env python3

from flask import Blueprint

bp = Blueprint('errors', __name__)

from DirectReport.browserview.errors import handlers
2 changes: 2 additions & 0 deletions DirectReport/browserview/errors/handlers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from flask import render_template, request
from DirectReport.browserview.errors import bp
from DirectReport.browserview.api.errors import error_response as api_error_response
Expand Down
8 changes: 6 additions & 2 deletions DirectReport/browserview/main/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env python3

from flask import Blueprint
from DirectReport.browserview.main import routes


bp = Blueprint('main', __name__)
bp: Blueprint = Blueprint('main', __name__)


from DirectReport.browserview.main import routes
Loading

0 comments on commit ef1dfb4

Please sign in to comment.