Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/cat3/src/partials/sections/dashboard/bots/bots.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
margin-top: 6px;
}

.margintop20 {
margin-top: -20px;
}

.boxWidth {
width:17%!important;
Expand Down Expand Up @@ -731,6 +728,9 @@ body .botDescriptionPage {
.firefoxForm {
margin-top: -20px;
}
.margintop20 {
margin-top: -20px;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
//{ name: 'BOT Created From',displayName: 'BOT Created From',field:'botLinkedCategory',cellTooltip: true},
{ name: 'Organization',field:'masterDetails.orgName',cellTooltip: true},
{ name: 'Last Run',field:'lastRunTime ',cellTemplate:'<span title="{{row.entity.lastRunTime | timestampToLocaleTime}}">{{row.entity.lastRunTime | timestampToLocaleTime}}</span>', cellTooltip: true},
{ name: 'Saved Time(Mins)',field:'savedTime', cellTooltip: true},
{ name: 'Saved Time',field:'savedTime', cellTemplate:'<span title="{{row.entity.savedTime.hours ? row.entity.savedTime.hours : 0}}h {{row.entity.savedTime.minutes ? row.entity.savedTime.minutes : 0}}m">{{row.entity.savedTime.hours ? row.entity.savedTime.hours : 0}}h {{row.entity.savedTime.minutes ? row.entity.savedTime.minutes : 0}}m</span>', cellTooltip: true},
{ name: 'Total Runs',field:'executionCount'},
{ name: 'BOT Action',width:200,displayName: 'BOT Action',cellTemplate:
'<a title="History"><i class="fa fa-header font-size-16 cursor" ng-click="grid.appScope.botHistory(row.entity);"></i></a>'+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<tr>
<td class="td-padding">Runlist</td>
<td>
{{botInfo.botConfig.runlist}}
{{botInfo.botConfig.runlist.join(",")}}
</td>
</tr>
<tr ng-show="botInfo.botConfig && botInfo.botConfig.attributes && botInfo.botConfig.attributes.length > 1" ng-repeat="attribs in botInfo.botConfig.attributes">
Expand Down
76 changes: 75 additions & 1 deletion server/app/cronjobs/task-sync/taskSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ var CatalystCronJob = require('_pr/cronjobs/CatalystCronJob');
var async = require('async');
var auditTrail = require('_pr/model/audit-trail/audit-trail.js');
var taskHistory = require('_pr/model/classes/tasks/taskHistory.js');
var botsDao = require('_pr/model/bots/1.0/bots.js');
var TaskSync = Object.create(CatalystCronJob);
TaskSync.interval = '*/5 * * * *';
TaskSync.interval = '*/2 * * * *';
TaskSync.execute = taskSync;

module.exports = TaskSync;
Expand All @@ -26,6 +27,9 @@ function taskSync(){
status:'running'
};
executeTaskSyncForTaskHistory(query,callback);
},
savedTimeSync : function(callback){
addSavedTimePerBots(callback);
}

},function(err,results){
Expand Down Expand Up @@ -153,4 +157,74 @@ function getMinutesDiff(date1,date2){
return Math.abs(Math.round(diff));
}

function getExecutionTime(endTime, startTime) {
var executionTimeInMS = endTime - startTime;
var totalSeconds = Math.floor(executionTimeInMS / 1000);
return totalSeconds;
}

function addSavedTimePerBots(callback) {
var query = {
isDeleted:false
}
botsDao.getAllBots(query,function(err,botList){
if(err){
callback(err,null);
return;
}else if(botList.length > 0){
var count = 0;
for(var i = 0; i<botList.length;i++){
(function(bots){
var query = {
auditType: 'BOTs',
actionStatus: 'success',
isDeleted: false,
auditId: bots.botId
};
auditTrail.getAuditTrails(query, function (err, botAuditTrail) {
if (err) {
logger.error("Error in Fetching Audit Trail.", err);
callback(err, null);
}
if (botAuditTrail.length > 0) {
var totalTimeInSeconds = 0;
for (var m = 0; m < botAuditTrail.length; m++) {
if (botAuditTrail[m].endedOn && botAuditTrail[m].endedOn !== null
&& botAuditTrail[m].auditTrailConfig.manualExecutionTime && botAuditTrail[m].auditTrailConfig.manualExecutionTime !== null) {
var executionTime = getExecutionTime(botAuditTrail[m].endedOn, botAuditTrail[m].startedOn);
totalTimeInSeconds = totalTimeInSeconds + ((botAuditTrail[m].auditTrailConfig.manualExecutionTime * 60) - executionTime);
}
}
var totalTimeInMinutes = Math.round(totalTimeInSeconds/60);
var result = {
hours:Math.floor(totalTimeInMinutes / 60),
minutes:totalTimeInMinutes % 60
}
botsDao.updateBotsDetail(bots.botId,{savedTime:result},function(err,data){
if(err){
logger.error(err);
}
count++;
if(count === botList.length){
callback(null,botList);
return;
}
})
} else {
count++;
if(count === botList.length){
callback(null,botList);
return;
}
}
});
})(botList[i]);
}
}else{
logger.debug("There is no BOTs for Saved Time Implementation.");
callback(null,botList);
}
})
}


10 changes: 8 additions & 2 deletions server/app/model/bots/1.0/bots.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,14 @@ var BotsSchema = new Schema ({
required: true
},
savedTime: {
type: Number,
default:0
hours:{
type: Number,
default:0
},
minutes:{
type: Number,
default:0
}
},
botConfig:Schema.Types.Mixed,
runTimeParams:Schema.Types.Mixed,
Expand Down
61 changes: 8 additions & 53 deletions server/app/services/botsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,32 +511,20 @@ function filterScriptBotsData(data,callback){
})(bots.botConfig.scriptDetails[j]);
}
if (scriptCount === bots.botConfig.scriptDetails.length) {
addSavedTimePerBots(bots.botId,function(err,savedTime) {
if (err) {
logger.error("Error in fetching Saved Time per bots ", err);
}
bots.savedTime = savedTime;
botsList.push(bots);
if (botsList.length === data.docs.length) {
data.docs = botsList;
callback(null, data);
return;
}
});
}
} else {
addSavedTimePerBots(bots.botId,function(err,savedTime) {
if (err) {
logger.error("Error in fetching Saved Time per bots ", err);
}
bots.savedTime = savedTime;
botsList.push(bots);
if (botsList.length === data.docs.length) {
data.docs = botsList;
callback(null, data);
return;
}
});
}
} else {
botsList.push(bots);
if (botsList.length === data.docs.length) {
data.docs = botsList;
callback(null, data);
return;
}
}
})(data.docs[i]);
}
Expand All @@ -559,39 +547,6 @@ function encryptedParam(paramDetails, callback) {
return;
}

function getExecutionTime(endTime, startTime) {
var executionTimeInMS = endTime - startTime;
var totalSeconds = Math.floor(executionTimeInMS / 1000);
return totalSeconds;
}

function addSavedTimePerBots(botId, callback) {
var query = {
auditType: 'BOTs',
actionStatus: 'success',
isDeleted: false,
auditId: botId
};
auditTrail.getAuditTrails(query, function (err, botAuditTrail) {
if (err) {
logger.error("Error in Fetching Audit Trail.", err);
callback(err, null);
}
if (botAuditTrail.length > 0) {
var totalTimeInSeconds = 0;
for (var m = 0; m < botAuditTrail.length; m++) {
if (botAuditTrail[m].endedOn && botAuditTrail[m].endedOn !== null
&& botAuditTrail[m].auditTrailConfig.manualExecutionTime && botAuditTrail[m].auditTrailConfig.manualExecutionTime !== null) {
var executionTime = getExecutionTime(botAuditTrail[m].endedOn, botAuditTrail[m].startedOn);
totalTimeInSeconds = totalTimeInSeconds + ((botAuditTrail[m].auditTrailConfig.manualExecutionTime * 60) - executionTime);
}
}
callback(null, (totalTimeInSeconds / 60).toFixed(2));
} else {
callback(null, 0);
}
});
}



Expand Down