这是indexloc提供的服务,不要输入任何密码
Skip to content

Add process to avoid messageTriggerLogExtractionIsSet message from appearing multiple times #296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2024
Merged
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
11 changes: 10 additions & 1 deletion src/websiteMonitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,14 @@ function extractStatusLogs(triggered = false) {
const targetWebsiteUrls = targetWebsitesArr.map((row) => {
let urlIndex = targetWebsitesHeader.indexOf(HEADER_NAME_TARGET_URL);
if (urlIndex < 0) {
// If the header name is not found, throw an error
let errorMessage = localMessage.replaceErrorHeaderNameTargetUrlNotFound(
HEADER_NAME_TARGET_URL,
SHEET_NAME_DASHBOARD,
);
if (triggered === true) {
// If this function is triggered by a time-based trigger,
// delete the trigger to avoid further errors.
ScriptApp.getProjectTriggers().forEach((trigger) => {
if (
ScriptApp.getHandlerFunction() === 'extractStatusLogsTriggered'
Expand Down Expand Up @@ -758,9 +761,12 @@ function extractStatusLogs(triggered = false) {
headersArr.forEach((headers) => {
headers.forEach((header, i) => {
if (header !== controlHeader[i]) {
// If the headers do not match, throw an error
let errorMessage =
localMessage.messageList.errorInconsistencyInHeader;
if (triggered === true) {
// If this function is triggered by a time-based trigger,
// delete the trigger to avoid further errors.
ScriptApp.getProjectTriggers().forEach((trigger) => {
if (
ScriptApp.getHandlerFunction() === 'extractStatusLogsTriggered'
Expand Down Expand Up @@ -829,6 +835,7 @@ function sendReminder() {
var messageSub = localMessage.messageList.mailSubSendReminderPrefix;
var messageBody = '';
try {
let extractStatusLogsTriggeredExists = false;
let triggerInfo = triggers
.reduce((info, trigger) => {
if (trigger.getHandlerFunction() === 'websiteMonitoringTriggered') {
Expand All @@ -853,11 +860,13 @@ function sendReminder() {
.join('\n')}`,
);
} else if (
trigger.getHandlerFunction() === 'extractStatusLogsTriggered'
trigger.getHandlerFunction() === 'extractStatusLogsTriggered' &&
!extractStatusLogsTriggeredExists
) {
info.push(
localMessage.messageList.messageTriggerLogExtractionIsSet,
);
extractStatusLogsTriggeredExists = true;
}
return info;
}, [])
Expand Down