Skip to content

Commit

Permalink
Code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mvignesh12 committed Jan 24, 2020
1 parent e6acd73 commit 5a4f588
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ public void tearDown(Run<?, ?> build, FilePath workspace, Launcher launcher, Tas
String passedBuildJob = build.getEnvironment(listener).expand(buildJob);
String passedPackageName = build.getEnvironment(listener).expand(packageName);
String doDeploy = build.getEnvironment(listener).expand("$UPDATE_ENV_DASH");
//List<ListItem> passedColumnData = Collections.emptyList();
// Pass column data to post-build runQuery
List<ListItem> passedColumnData = new ArrayList<ListItem>();
if (addColumns) {
Expand Down Expand Up @@ -180,7 +179,7 @@ public void tearDown(Run<?, ?> build, FilePath workspace, Launcher launcher, Tas
context.setDisposer(new TearDownImpl());
}


@SuppressWarnings("rawtypes")
private String writeToDB(Run<?, ?> build, TaskListener listener, String envName, String compName,
String currentBuildNum, String runTime, String buildJob, Integer numberOfDays, String packageName,
List<ListItem> passedColumnData) {
Expand Down Expand Up @@ -224,7 +223,7 @@ private String writeToDB(Run<?, ?> build, TaskListener listener, String envName,
returnComment = "WARN: Could not alter table env_dashboard to add column " + item.columnName + ".";
return returnComment;
}
}
}
String indexValueofTable = envName + '=' + compName;
String currentBuildResult = "UNKNOWN";
if (build.getResult() == null && runTime.equals("PRE")) {
Expand All @@ -250,18 +249,18 @@ private String writeToDB(Run<?, ?> build, TaskListener listener, String envName,
runQuery = "INSERT INTO env_dashboard (envComp, jobUrl, buildNum, buildStatus, envName, compName, created_at, buildJobUrl, packageName"
+ columns + ") VALUES( '" + indexValueofTable + "', '" + currentBuildUrl + "', '" + currentBuildNum
+ "', '" + currentBuildResult + "', '" + envName + "', '" + compName + "' , + current_timestamp, '"
+ buildJobUrl + "' , '" + packageName + contents + "');";
+ buildJobUrl + "' , '" + packageName + contents + "');";
} else {
if (runTime.equals("POST")) {
if (runTime.equals("POST")) {
// Updates build no. and additional columns also in post-build update
String updateColumns = "";
for (ListItem item : passedColumnData) {
updateColumns += "," + item.columnName + "=" + "'" + item.contents + "'";
updateColumns += "," + item.columnName + "=" + "'" + item.contents + "'";
}
runQuery = "UPDATE env_dashboard SET buildNum = '" + currentBuildNum + "', buildStatus = '" + currentBuildResult
+ "', created_at = current_timestamp " + updateColumns + " WHERE envComp = '" + indexValueofTable + "' AND joburl = '"
+ currentBuildUrl + "';";
listener.getLogger().println("DEBUG: Final Post-Build runQuery:" + runQuery);
listener.getLogger().println("DEBUG: Final Post-Build runQuery:" + runQuery);
} else {
if (runTime.equals("NODEPLOY")) {
runQuery = "DELETE FROM env_dashboard where envComp = '" + indexValueofTable + "' AND joburl = '"
Expand All @@ -273,7 +272,7 @@ private String writeToDB(Run<?, ?> build, TaskListener listener, String envName,
stat.execute(runQuery);
} catch (SQLException e) {
returnComment = "Error running query " + runQuery + ".";
return returnComment + e;
return returnComment;
}
if (numberOfDays > 0) {
runQuery = "DELETE FROM env_dashboard where created_at <= current_timestamp - " + numberOfDays;
Expand Down

0 comments on commit 5a4f588

Please sign in to comment.