Skip to content

Commit

Permalink
Remove sendEmail method (#155)
Browse files Browse the repository at this point in the history
* Remove sendEmail method

Use sentry to capture exception instead.
  • Loading branch information
zhx828 authored Jun 15, 2023
1 parent 8810dd9 commit 3c771fc
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 672 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ For example, if concokb-core runs at `http://localhost:8888/oncokb`, you should
...
```

## Testing
For front-end, we use Karma and Jasmin to run unit test cases.
1. Install karma-cli (globally).
2. Copy /app/data/config.json to **OncoKB.config** in /app/scripts/app.spec.js.
3. Run **karma start** at root folder.

## FAQs
#### Can’t getAllUsers() because of the different rules set in Firebase. It still shows 'don’t have access...' after logging in successfully.
Add rules to the database.
Expand Down
1 change: 0 additions & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@
<script src="scripts/factories/TreeFactory.js"></script>
<script src="scripts/factories/VariantFactory.js"></script>
<script src="scripts/controllers/VariantCtrl.js"></script>
<script src="scripts/controllers/emailDialogCtrl.js"></script>
<script src="scripts/controllers/VUSCtrl.js"></script>
<script src="scripts/filters/Filter.js"></script>
<script src="scripts/directives/regularview.js"></script>
Expand Down
414 changes: 0 additions & 414 deletions app/scripts/app.spec.js

This file was deleted.

1 change: 0 additions & 1 deletion app/scripts/controllers/drugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ angular.module('oncokbApp')
}, function(reason) {
// something goes wrong then the data in database should not be updated.
});
mainUtils.sendEmailtoMultipulUsers(['[email protected]', '[email protected]', '[email protected]'], 'Reminder: A therapy preferred name changed.', content);
}
}
};
Expand Down
16 changes: 0 additions & 16 deletions app/scripts/controllers/emailDialogCtrl.js

This file was deleted.

13 changes: 1 addition & 12 deletions app/scripts/controllers/gene.js
Original file line number Diff line number Diff line change
Expand Up @@ -3387,18 +3387,7 @@ angular.module('oncokbApp')
}, function (error) {
// Something goes wrong, this needs to be stored into meta file for future update.
console.log('Failed to update priority.');
DatabaseConnector.sendEmail({
sendTo: '[email protected]',
subject: 'Error when updating treatments\' priority',
content: JSON.stringify(postData)
},
function (result) {
deferred.rejected(error);
},
function (error) {
deferred.rejected(error);
}
);
Sentry.captureException(new Exception('Error when updating treatments\' priority. Data: ' + JSON.stringify(postData)));
});
} else {
deferred.resolve();
Expand Down
1 change: 0 additions & 1 deletion app/scripts/controllers/genes.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ angular.module('oncokbApp')
rendering: true,
queueRendering: true
};
$scope.adminEmails = [];
$scope.oncoTree = {
mainTypes: {}
};
Expand Down
3 changes: 1 addition & 2 deletions app/scripts/controllers/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ angular.module('oncokbApp')
$location.url('/genes');
}
}, function(error) {
mainUtils.sendEmail('[email protected]', 'Failed to set user role.',
'Content: \n' + JSON.stringify(firebaseUser) + '\n\nError: \n' + JSON.stringify(error));
Sentry.captureException(new Exception('Failed to set user role. Content: \n' + JSON.stringify(firebaseUser) + '\n\nError: \n' + JSON.stringify(error)));
});
} else {
console.log('not logged in yet');
Expand Down
1 change: 0 additions & 1 deletion app/scripts/directives/createnewdrug.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ angular.module('oncokbApp')
$scope.addDrugErrorMessage = 'Failed to create the drug ' + drugName + '! Please contact developers.';
deferred.reject(error);
});
mainUtils.sendEmailtoMultipulUsers(['[email protected]', '[email protected]', '[email protected]'], 'Reminder: A therapy has been added.', content);
}
else {
$scope.addDrugErrorMessage = "Sorry, same drug exists.";
Expand Down
77 changes: 0 additions & 77 deletions app/scripts/directives/curationQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ angular.module('oncokbApp')
formExpanded: false,
editing: false,
hugoVariantMapping: {},
resendEmail: false,
queueItemInEditing: '',
invalidData: false,
hugoSymbols: [],
loading: true
};
scope.resendEmail = false;
scope.input = {
article: '',
link: '',
Expand Down Expand Up @@ -83,7 +81,6 @@ angular.module('oncokbApp')
});
}
scope.data.loading = false;
scope.secondTimeAutoNotify();
});
// The column difference in terms of curation queue location in queues page or gene page it that,
// gene page has an unique column 'Previously curated in', and queues page has an unique column 'Gene'
Expand Down Expand Up @@ -206,9 +203,6 @@ angular.module('oncokbApp')
currentQueues.push(item);
$scope.updateQueueInDB(hugoSymbol, currentQueues).then(function(result) {
$scope.queue.push(item);
if (item.curator) {
$scope.sendEmail(item);
}
});
}
$scope.initialProcess = function(x, type) {
Expand Down Expand Up @@ -239,7 +233,6 @@ angular.module('oncokbApp')
};

function editCuration(queueItem) {
$scope.data.resendEmail = false;
$scope.data.editing = true;
$scope.data.queueItemInEditing = queueItem;
$scope.data.modifiedCurator = {};
Expand Down Expand Up @@ -334,9 +327,6 @@ angular.module('oncokbApp')
_.each(_.keys(item), function(key) {
$scope.data.queueItemInEditing[key] = item[key];
});
if ($scope.resendEmail) {
$scope.sendEmail(queueItem);
}
});
}
function completeCuration(queueItem) {
Expand Down Expand Up @@ -417,60 +407,6 @@ angular.module('oncokbApp')
console.log('error');
});
};
$scope.sendEmail = function(queueItem) {
var expiredCuration = false;
if ($scope.isExpiredCuration(queueItem.dueDay)) {
expiredCuration = true;
}
var email = '';
for (var i = 0; i < $scope.data.curators.length; i++) {
if (queueItem.curator === $scope.data.curators[i].name) {
email = $scope.data.curators[i].email;
break;
}
}
if (!email) return;
var content = 'Dear ' + queueItem.curator.split(' ')[0] + ',\n\n';
if (expiredCuration) {
content += 'You have not completed curation of the assigned publication: ' + queueItem.article;
if (queueItem.link) {
content += '(' + queueItem.link + ')';
}
content += ' which was due on ' + $scope.getFormattedDate(queueItem.dueDay) + '. Please complete this assignment as soon as possible and let us know when you have done this. \n\nIf you have already completed this task, please remember to CLICK THE GREEN CHECK BOX BUTTON at the Curation Queue page or the bottom of the gene page (this will let us know the task is complete). If you have any questions or concerns please email or slack us as needed.';
content += 'Thank you, \nOncoKB Admin';
} else {
content += queueItem.addedBy + ' of OncoKB would like you curate the following publications in the indicated alteration, tumor type and section:\n\n';
var tempArr = [queueItem.article];
if (queueItem.link) {
tempArr = tempArr.concat(['(', queueItem.link, ')']);
}
if (queueItem.variant) {
tempArr = tempArr.concat(['Alteration:', queueItem.variant + ',']);
}
if (queueItem.subType) {
tempArr = tempArr.concat(['Tumor type:', queueItem.subType + ',']);
}
if (queueItem.section) {
tempArr = tempArr.concat(['Section:', queueItem.section]);
}
content += tempArr.join(' ') + '\n';
if (queueItem.comment) {
content += queueItem.comment + '\n';
}
content += '\nPlease try to curate this literature before ' + $scope.getFormattedDate(queueItem.dueDay) + ' and remember to log your hours for curating this data.\n\n';
content += 'IMPORTANT: Please remember to CLICK THE GREEN CHECK BOX BUTTON at the Curation Queue page or the bottom of the gene page (this will let us know the task is complete).\n\n';
content += 'If you have any questions or concerns please email or slack ' + queueItem.addedBy + '.\n\n';
content += 'Thank you, \nOncoKB Admin';
}
var subject = 'OncoKB Curation Assignment';
mainUtils.sendEmail(email, subject, content).then(function() {
if (expiredCuration) {
setCurationNotified(queueItem);
}
}, function(error) {
dialogs.error('Error', 'Failed to notify curator automatically. Please send curator email manually.');
});
};

var annotationLocation = $scope.specifyAnnotationInGene();
$scope.getAnnotationLocation = function(x) {
Expand Down Expand Up @@ -513,7 +449,6 @@ angular.module('oncokbApp')
$scope.data.editing = false;
$scope.predictedArticle = '';
$scope.validPMID = false;
$scope.data.resendEmail = false;
};
$scope.isExpiredCuration = mainUtils.isExpiredCuration;
$scope.checkInput = function() {
Expand All @@ -526,20 +461,8 @@ angular.module('oncokbApp')
if ($scope.data.editing && !$scope.data.invalidData) {
if ($scope.input.curator && queueItem.curator !== $scope.input.curator.name ||
$scope.input.dueDay && queueItem.dueDay !== new Date($scope.input.dueDay).getTime()) {
$scope.data.resendEmail = true;
} else {
$scope.data.resendEmail = false;
}
}
$scope.resendEmail = $scope.data.resendEmail;
};
$scope.secondTimeAutoNotify = function() {
_.each($scope.queue, function (queueItem) {
var hugoSymbol = queueItem.hugoSymbol;
if (hugoSymbol && queueItem.curator && !queueItem.curated && mainUtils.isExpiredCuration(queueItem.dueDay) && !queueItem.notified) {
$scope.sendEmail(queueItem);
}
});
};
$scope.getQueuesByGene = function(hugoSymbol) {
return $rootScope.firebaseQueues[hugoSymbol] ? angular.copy($rootScope.firebaseQueues[hugoSymbol].queue) : [];
Expand Down
21 changes: 0 additions & 21 deletions app/scripts/factories/VariantFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,27 +154,6 @@ angular.module('oncokbApp').config(function($httpProvider) {
};
}]);

angular.module('oncokbApp').factory('SendEmail', ['$http', 'OncoKB', function($http, OncoKB) {
'use strict';
var transform = function(data) {
return $.param(data);
};

function init(params) {
return $http.post(
OncoKB.config.curationLink + 'sendEmail',
params,
{
headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
transformRequest: transform
});
}

return {
init: init
};
}]);

angular.module('oncokbApp').factory('DriveAnnotation', ['$http', 'OncoKB', '_', function($http, OncoKB, _) {
'use strict';
var transform = function(data) {
Expand Down
53 changes: 7 additions & 46 deletions app/scripts/services/databaseconnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ angular.module('oncokbApp')
'Evidence',
'SearchVariant',
'DriveAnnotation',
'SendEmail',
'Sentry',
'onLocalhost',
'DataSummary',
'Drugs',
Expand All @@ -29,7 +29,7 @@ angular.module('oncokbApp')
Evidence,
SearchVariant,
DriveAnnotation,
SendEmail,
Sentry,
onLocalhost,
DataSummary,
Drugs,
Expand All @@ -51,16 +51,7 @@ angular.module('oncokbApp')
.then(function(data) {
deferred.resolve(data.data);
}, function(error) {
var subject = 'searchDrugs Error';
var content = 'The system error returned is ' + JSON.stringify(error);
sendEmail({sendTo: '[email protected]', subject: subject, content: content},
function(result) {
console.log('sent searchDrugs Error to oncokb dev account');
},
function(error) {
console.log('fail to send searchDrugs Error to oncokb dev account', error);
}
);
Sentry.captureException(new Exception('Failed to add a new history record for ' + hugoSymbol + '. \n\n Content: ' + JSON.stringify(historyData) + '\n\nError: \n' + JSON.stringify(error)));
deferred.reject(error);
});
return deferred.promise;
Expand Down Expand Up @@ -246,16 +237,9 @@ angular.module('oncokbApp')
.then(function(data) {
success(data);
}, function(error) {
var subject = 'VUS update Error for ' + hugoSymbol;
var content = 'The system error returned is ' + JSON.stringify(error);
sendEmail({sendTo: '[email protected]', subject: subject, content: content},
function(result) {
console.log('sent old history to oncokb dev account');
},
function(error) {
console.log('fail to send old history to oncokb dev account', error);
}
);
var content = 'VUS update Error for ' + hugoSymbol;
content = content + '\nThe system error returned is ' + JSON.stringify(error);
Sentry.captureException(new Exception(content));
fail(error);
setAPIData('vus', hugoSymbol, data);
});
Expand Down Expand Up @@ -312,20 +296,6 @@ angular.module('oncokbApp')
return DriveAnnotation.updateEvidenceRelevantCancerTypesBatch(data);
}

function sendEmail(params, success, fail) {
if (testing || !inProduction) {
success(true);
} else {
SendEmail
.init(params)
.then(function(data) {
success(data);
}, function() {
fail();
});
}
}

function timeout(callback, timestamp) {
$timeout(function() {
if (numOfLocks[timestamp] === 0) {
Expand Down Expand Up @@ -490,15 +460,7 @@ angular.module('oncokbApp')
}).then(function(ref) {
console.log('Added a new history record.');
}, function (error) {
sendEmail({sendTo: '[email protected]', subject: 'Failed to add a new history record for ' + hugoSymbol
+ '.', content: JSON.stringify(historyData) + '\n\nError: \n' + JSON.stringify(error)},
function(result) {
console.log('sent history error to oncokb dev account');
},
function(error) {
console.log('fail to send history error to oncokb dev account', error);
}
);
Sentry.captureException(new Exception('Failed to add a new history record for ' + hugoSymbol + '. \n\n Content: ' + JSON.stringify(historyData) + '\n\nError: \n' + JSON.stringify(error)));
});
}

Expand Down Expand Up @@ -585,7 +547,6 @@ angular.module('oncokbApp')
updateEvidenceTreatmentPriorityBatch: updateEvidenceTreatmentPriorityBatch,
updateEvidenceRelevantCancerTypesBatch: updateEvidenceRelevantCancerTypesBatch,
addHistoryRecord: addHistoryRecord,
sendEmail: sendEmail,
getCacheStatus: getCacheStatus,
updateGeneCache: function(hugoSymbol) {
return updateGeneCache(hugoSymbol);
Expand Down
Loading

0 comments on commit 3c771fc

Please sign in to comment.