Skip to content

Commit

Permalink
adding make_pie_dict to have a happy linter
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrnull committed Mar 25, 2024
1 parent fa4cb29 commit c2372d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
28 changes: 3 additions & 25 deletions dashboard/src/t5gweb/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)
from t5gweb.t5gweb import get_new_cases, get_new_comments, get_trending_cards, plots
from t5gweb.taskmgr import refresh_background
from t5gweb.utils import set_cfg
from t5gweb.utils import set_cfg, make_pie_dict

BP = Blueprint("ui", __name__, url_prefix="/")
login_manager = LoginManager()
Expand Down Expand Up @@ -386,18 +386,7 @@ def get_account(account):
load_data()
stats = generate_stats(account)
comments = get_new_comments(new_comments_only=False, account=account)

pie_stats = {
"by_severity": (
list(stats["by_severity"].keys()),
list(stats["by_severity"].values()),
),
"by_status": (
list(stats["by_status"].keys()),
list(stats["by_status"].values()),
),
}

pie_stats = make_pie_dict(stats)
histogram_stats = generate_histogram_stats(account)
return render_template(
"ui/account.html",
Expand All @@ -419,18 +408,7 @@ def get_engineer(engineer):
load_data()
stats = generate_stats(engineer=engineer)
comments = get_new_comments(new_comments_only=False, engineer=engineer)

pie_stats = {
"by_severity": (
list(stats["by_severity"].keys()),
list(stats["by_severity"].values()),
),
"by_status": (
list(stats["by_status"].keys()),
list(stats["by_status"].values()),
),
}

pie_stats = make_pie_dict(stats)
histogram_stats = generate_histogram_stats(engineer=engineer)
return render_template(
"ui/account.html",
Expand Down
14 changes: 14 additions & 0 deletions dashboard/src/t5gweb/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,17 @@ def slack_notify(ini, blist):
)
except SlackApiError as slack_error:
logging.warning("failed to post to slack: %s", slack_error)


def make_pie_dict(stats):
"""get the code simplified"""
return {
"by_severity": (
list(stats["by_severity"].keys()),
list(stats["by_severity"].values()),
),
"by_status": (
list(stats["by_status"].keys()),
list(stats["by_status"].values()),
),
}

0 comments on commit c2372d2

Please sign in to comment.