Skip to content

Commit

Permalink
UI show the % of successful deployments per primary or sub account (#…
Browse files Browse the repository at this point in the history
…1288)

* UI show the % of successful deployments per primary or sub account

* remove test code

* fix typo
  • Loading branch information
liyaqin1 authored Oct 7, 2023
1 parent 8f6a367 commit 4cdaa91
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 7 deletions.
52 changes: 52 additions & 0 deletions deploy-board/deploy_board/webapp/env_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,32 @@ def update_deploy_progress(request, name, stage):

report.showMode = showMode
report.sortByStatus = sortByStatus

# Get the host number for subAcct and primaryAcct
report.currentDeployStat.deploy["showMode"] = showMode
report.currentDeployStat.deploy["subAcctTotalHostNum"] = 0
report.currentDeployStat.deploy["subAcctSucHostNum"] = 0
report.currentDeployStat.deploy["subAcctFailHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctTotalHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctSucHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctFailHostNum"] = 0
if showMode == "subAcct":
for agentStat in report.agentStats:
if agentStat.agent["accountId"] and agentStat.agent["accountId"] != "998131032990" and agentStat.agent["accountId"] != "null":
report.currentDeployStat.deploy["subAcctTotalHostNum"] += 1
if agentStat.agent["status"] == "SUCCEEDED":
report.currentDeployStat.deploy["subAcctSucHostNum"] += 1
else:
report.currentDeployStat.deploy["subAcctFailHostNum"] += 1
elif showMode == "primaryAcct":
for agentStat in report.agentStats:
if not agentStat.agent["accountId"] or agentStat.agent["accountId"] == "998131032990" or agentStat.agent["accountId"] == "null":
report.currentDeployStat.deploy["primaryAcctTotalHostNum"] += 1
if agentStat.agent["status"] == "SUCCEEDED":
report.currentDeployStat.deploy["primaryAcctSucHostNum"] += 1
else:
report.currentDeployStat.deploy["primaryAcctFailHostNum"] += 1

context = {
"report": report,
"env": env,
Expand Down Expand Up @@ -415,6 +441,32 @@ def get(self, request, name, stage=None):
report = agent_report.gen_report(request, env, progress, sortByStatus=sortByStatus)
report.showMode = showMode
report.sortByStatus = sortByStatus

# Get the host number for subAcct and primaryAcct
report.currentDeployStat.deploy["showMode"] = showMode
report.currentDeployStat.deploy["subAcctTotalHostNum"] = 0
report.currentDeployStat.deploy["subAcctSucHostNum"] = 0
report.currentDeployStat.deploy["subAcctFailHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctTotalHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctSucHostNum"] = 0
report.currentDeployStat.deploy["primaryAcctFailHostNum"] = 0
if showMode == "subAcct":
for agentStat in report.agentStats:
if agentStat.agent["accountId"] and agentStat.agent["accountId"] != "998131032990" and agentStat.agent["accountId"] != "null":
report.currentDeployStat.deploy["subAcctTotalHostNum"] += 1
if agentStat.agent["status"] == "SUCCEEDED":
report.currentDeployStat.deploy["subAcctSucHostNum"] += 1
else:
report.currentDeployStat.deploy["subAcctFailHostNum"] += 1
elif showMode == "primaryAcct":
for agentStat in report.agentStats:
if not agentStat.agent["accountId"] or agentStat.agent["accountId"] == "998131032990" or agentStat.agent["accountId"] == "null":
report.currentDeployStat.deploy["primaryAcctTotalHostNum"] += 1
if agentStat.agent["status"] == "SUCCEEDED":
report.currentDeployStat.deploy["primaryAcctSucHostNum"] += 1
else:
report.currentDeployStat.deploy["primaryAcctFailHostNum"] += 1

context = {
"envs": envs,
"env": env,
Expand Down
37 changes: 30 additions & 7 deletions deploy-board/deploy_board/webapp/templatetags/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,15 @@ def deployAcceptanceTip(status):

@register.filter("progressTip")
def progressTip(deploy):
return "Among total %d hosts, %d are succeeded and %d are stuck" % (
deploy["total"], deploy["successTotal"], deploy["failTotal"])
if deploy["showMode"] == "subAcct":
return "Among total %d hosts, %d are succeeded and %d are stuck" % (
deploy["subAcctTotalHostNum"], deploy["subAcctSucHostNum"], deploy["subAcctFailHostNum"])
elif deploy["showMode"] == "primaryAcct":
return "Among total %d hosts, %d are succeeded and %d are stuck" % (
deploy["primaryAcctTotalHostNum"], deploy["primaryAcctSucHostNum"], deploy["primaryAcctFailHostNum"])
else:
return "Among total %d hosts, %d are succeeded and %d are stuck" % (
deploy["total"], deploy["successTotal"], deploy["failTotal"])


@register.filter("deployStateTip")
Expand Down Expand Up @@ -432,15 +439,31 @@ def getTotalDuration(start, end=None):
@register.filter("successRate")
def successRate(deploy):
rate = 0
if deploy["total"] != 0:
rate = trunc(deploy["successTotal"] * 100 / deploy["total"])
return "%d%% (%d/%d)" % (rate, deploy["successTotal"], deploy["total"])
if deploy["showMode"] == "subAcct":
if deploy["subAcctTotalHostNum"] != 0:
rate = trunc(deploy["subAcctSucHostNum"] * 100 / deploy["subAcctTotalHostNum"])
return "%d%% (%d/%d)" % (rate, deploy["subAcctSucHostNum"], deploy["subAcctTotalHostNum"])
elif deploy["showMode"] == "primaryAcct":
if deploy["primaryAcctTotalHostNum"] != 0:
rate = trunc(deploy["primaryAcctSucHostNum"] * 100 / deploy["primaryAcctTotalHostNum"])
return "%d%% (%d/%d)" % (rate, deploy["primaryAcctSucHostNum"], deploy["primaryAcctTotalHostNum"])
else:
if deploy["total"] != 0:
rate = trunc(deploy["successTotal"] * 100 / deploy["total"])
return "%d%% (%d/%d)" % (rate, deploy["successTotal"], deploy["total"])


@register.filter("successRatePercentage")
def successRatePercentage(deploy):
if deploy["total"] != 0:
return trunc(deploy["successTotal"] * 100 / deploy["total"])
if deploy["showMode"] == "subAcct":
if deploy["subAcctTotalHostNum"] != 0:
return trunc(deploy["subAcctSucHostNum"] * 100 / deploy["subAcctTotalHostNum"])
elif deploy["showMode"] == "primaryAcct":
if deploy["primaryAcctTotalHostNum"] != 0:
return trunc(deploy["primaryAcctSucHostNum"] * 100 / deploy["primaryAcctTotalHostNum"])
else:
if deploy["total"] != 0:
return trunc(deploy["successTotal"] * 100 / deploy["total"])
return 0


Expand Down

0 comments on commit 4cdaa91

Please sign in to comment.