Skip to content

Commit

Permalink
Merge pull request #279 from npalchur/ui-file-changes
Browse files Browse the repository at this point in the history
removing the load_data function from multiple places
  • Loading branch information
adhil0 authored Mar 27, 2024
2 parents 024782b + 804e529 commit 0a60479
Showing 1 changed file with 35 additions and 37 deletions.
72 changes: 35 additions & 37 deletions dashboard/src/t5gweb/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ def login():
@login_required
def index():
"""list new cases"""
load_data()
plot_data = plots()
return render_template(
"ui/index.html",
new_cases=load_data.new_cases,
values=load_data.y,
now=load_data.now,
new_cases=get_new_cases(),
values=list(plot_data.values()),
now=redis_get("timestamp"),
)


Expand Down Expand Up @@ -268,20 +268,19 @@ def refresh_status(task_id):
def refresh():
"""Forces an update to the dashboard"""
task = refresh_background.delay()
load_data()
return jsonify({}), 202, {"Location": url_for("ui.refresh_status", task_id=task.id)}


@BP.route("/updates/")
@login_required
def report_view():
"""Retrieves cards that have been updated within the last week and creates report"""
load_data()
cfg = set_cfg()
return render_template(
"ui/updates.html",
now=load_data.now,
new_comments=load_data.accounts,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_new_comments(),
jira_server=cfg["server"],
page_title="recent updates",
)

Expand All @@ -290,12 +289,12 @@ def report_view():
@login_required
def report_view_all():
"""Retrieves all cards and creates report"""
load_data()
cfg = set_cfg()
return render_template(
"ui/updates.html",
now=load_data.now,
new_comments=load_data.accounts_all,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_new_comments(new_comments_only=False),
jira_server=cfg["server"],
page_title="all cards",
)

Expand All @@ -306,12 +305,12 @@ def trends():
"""Retrieves cards that have been labeled with 'Trends' within
the previous quarter and creates report
"""
load_data()
cfg = set_cfg()
return render_template(
"ui/updates.html",
now=load_data.now,
new_comments=load_data.trending_cards,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_trending_cards(),
jira_server=cfg["server"],
page_title="trends",
)

Expand All @@ -320,12 +319,12 @@ def trends():
@login_required
def table_view():
"""Sorts new cards by severity and creates table"""
load_data()
cfg = set_cfg()
return render_template(
"ui/table.html",
now=load_data.now,
new_comments=load_data.accounts,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_new_comments(),
jira_server=cfg["server"],
page_title="severity",
)

Expand All @@ -334,12 +333,12 @@ def table_view():
@login_required
def table_view_all():
"""Sorts all cards by severity and creates table"""
load_data()
cfg = set_cfg()
return render_template(
"ui/table.html",
now=load_data.now,
new_comments=load_data.accounts_all,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_new_comments(new_comments_only=False),
jira_server=cfg["server"],
page_title="all-severity",
)

Expand All @@ -350,12 +349,12 @@ def weekly_updates():
"""Retrieves cards and displays them plainly for easy copy/pasting
and distribution
"""
load_data()
cfg = set_cfg()
return render_template(
"ui/weekly_report.html",
now=load_data.now,
new_comments=load_data.accounts,
jira_server=load_data.jira_server,
now=redis_get("timestamp"),
new_comments=get_new_comments(),
jira_server=cfg["server"],
page_title="weekly-update",
)

Expand All @@ -364,13 +363,12 @@ def weekly_updates():
@login_required
def get_stats():
"""generate some stats"""
load_data()
stats = generate_stats()
x_values, y_values = plot_stats()
histogram_stats = generate_histogram_stats()
return render_template(
"ui/stats.html",
now=load_data.now,
now=redis_get("timestamp"),
stats=stats,
x_values=x_values,
y_values=y_values,
Expand All @@ -383,7 +381,7 @@ def get_stats():
@login_required
def get_account(account):
"""show bugs, cases and stats by for a given account"""
load_data()
cfg = set_cfg()
stats = generate_stats(account)
comments = get_new_comments(new_comments_only=False, account=account)
pie_stats = make_pie_dict(stats)
Expand All @@ -392,10 +390,10 @@ def get_account(account):
"ui/account.html",
page_title=account,
account=account,
now=load_data.now,
now=redis_get("timestamp"),
stats=stats,
new_comments=comments,
jira_server=load_data.jira_server,
jira_server=cfg["server"],
pie_stats=pie_stats,
histogram_stats=histogram_stats,
)
Expand All @@ -405,7 +403,7 @@ def get_account(account):
@login_required
def get_engineer(engineer):
"""show bugs, cases and stats by for a given engineer"""
load_data()
cfg = set_cfg()
stats = generate_stats(engineer=engineer)
comments = get_new_comments(new_comments_only=False, engineer=engineer)
pie_stats = make_pie_dict(stats)
Expand All @@ -414,10 +412,10 @@ def get_engineer(engineer):
"ui/account.html",
page_title=engineer,
account=engineer,
now=load_data.now,
now=redis_get("timestamp"),
stats=stats,
new_comments=comments,
jira_server=load_data.jira_server,
jira_server=cfg["server"],
pie_stats=pie_stats,
histogram_stats=histogram_stats,
engineer_view=True,
Expand Down

0 comments on commit 0a60479

Please sign in to comment.