Skip to content

Commit 9f785b5

Browse files
committed
C50-568 getAllBots api that return based default github id
1 parent 0461f99 commit 9f785b5

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

server/app/services/botService.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,6 @@ botService.syncSingleBotsWithGitHub = function syncSingleBotsWithGitHub(botId, c
731731
});
732732
}
733733

734-
735734
botService.syncBotsWithGitHub = function syncBotsWithGitHub(gitHubId, callback) {
736735
async.waterfall([
737736
function (next) {
@@ -1353,7 +1352,6 @@ function removeScriptFile(filePath) {
13531352
})
13541353
}
13551354

1356-
13571355
botService.getBotBysource = function (source, callback) {
13581356
var query = {};
13591357
var fields = { repositoryName: 1, _id: 1 };
@@ -1477,8 +1475,23 @@ botService.getAllBotsList = function getAllBotsList(botsQuery, userName, callbac
14771475
if (err) {
14781476
next(err, null);
14791477
} else if (orgIds.length > 0) {
1480-
queryObj.queryObj['orgId'] = { $in: orgIds };
1481-
botDao.getBotsList(queryObj, next);
1478+
var query = {
1479+
"orgId": { $in: orgIds },
1480+
"isDefault": 'true'
1481+
};
1482+
var fields;
1483+
gitHubModel.getGitRepository(query, fields, (err, res) => {
1484+
if (!err && res.length > 0) {
1485+
queryObj.queryObj['orgId'] = { $in: orgIds };
1486+
queryObj.queryObj['gitHubId'] = res[0]._id;
1487+
botDao.getBotsList(queryObj, next);
1488+
}
1489+
else {
1490+
logger.error("Default Github account not found for OrgIDs: " + orgIds);
1491+
queryObj.queryObj['gitHubId'] = '';
1492+
botDao.getBotsList(queryObj, next);
1493+
}
1494+
});
14821495
} else {
14831496
botDao.getBotsList(queryObj, next);
14841497
}

server/app/services/gitHubService.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ gitGubService.getGitHubSync = function getGitHubSync(gitHubId,task, callback) {
147147
}else{
148148
cmd = 'curl -L ' + burl + '/repos/'+formattedGitHub.repositoryOwner+'/'+formattedGitHub.repositoryName+'/archive?AT='+formattedGitHub.repositoryOwner+'/'+formattedGitHub.repositoryName+'/get/'+formattedGitHub.repositoryBranch + '.tar.gz > '+appConfig.botFactoryDir+formattedGitHub.repositoryName+'.tgz';
149149
}
150-
}
151-
logger.info(cmd);
150+
};
152151
gitHubCloning(formattedGitHub,task,cmd,function(err,res){
153152
if(err){
154153
callback(err,null);

0 commit comments

Comments
 (0)