Skip to content

Commit

Permalink
use appid instead of appname
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Taylor <steve@deployhub.com>
  • Loading branch information
sbtaylor15 committed Oct 4, 2024
1 parent ee9c7b8 commit f7e6b1c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"env":{"DB_PASS": "InS0mn1a+15", "DB_PORT": "55432"}
}
]
}
17 changes: 15 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,28 @@ async def get_scorecard( # noqa: C901
envorder.append(row[0])

if frequency is not None:

parentid = -1

if appid is not None:
app_cursor = conn.cursor()
params = tuple([appid, appid])
app_cursor.execute("select distinct coalesce(parentid,id) as parentid from dm.dm_application where id = %s or parentid = %s", params)
rows = app_cursor.fetchall()

for row in rows:
parentid = row[0] if row[0] else -1
break

data = ScoreCard()

sqlstmt = (
"select application, environment, (monthly::date)::varchar as month, count(monthly) as frequency from dm.dm_app_scorecard "
"where application=:appname "
"where parentid=:parentid "
"group by application, month, environment "
"order by application, month desc, environment"
)
df = pd.read_sql(sql.text(sqlstmt), connection, params={"appname": appname})
df = pd.read_sql(sql.text(sqlstmt), connection, params={"parentid": parentid})

if len(df.index) > 0:
table = df.pivot_table(values=["frequency"], index=["application", "environment", "month"], columns=["month"])
Expand Down
7 changes: 3 additions & 4 deletions reports/frequency.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
}

$(document).ready(function () {
var appname = getParameterByName("appname");
var url = "/msapi/scorecard?frequency=y&appname=" + appname;
var appname = getParameterByName("appid");
var url = "/msapi/scorecard?frequency=y&appid=" + appname;

$("#scorecardtitle").html(appname + " Deployment Frequency By Environment Per Month");
$("#scorecardtitle").html(" Deployment Frequency By Environment Per Month");

$.getJSON(url,
function (data) {
Expand Down Expand Up @@ -92,7 +92,6 @@
</script>

<div class="centerdiv">
<img id="scorecard-logo" src="https://console.deployhub.com/dmadminweb/images/logo.png" alt="deployhub logo" width="157px" height="27px" />
<h2 id="scorecardtitle" class="fg-white"></h2>
</div>
<div class="top-120">
Expand Down
3 changes: 1 addition & 2 deletions reports/lag.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@
</style>

<div class="centerdiv">
<img id="scorecard-logo" src="https://console.deployhub.com/dmadminweb/images/logo.png" alt="deployhub logo" width="157px" height="27px" />
<h2 id="scorecardtitle" class="fg-white"></h2>
<h2 id="scorecardtitle" class="fg-white"></h2>
</div>
<div class="top-120">
<div id="stackedbarchart" height="100%" ></div>
Expand Down

0 comments on commit f7e6b1c

Please sign in to comment.