Skip to content

Commit

Permalink
Improve notifications display
Browse files Browse the repository at this point in the history
  • Loading branch information
nvuillam committed Sep 8, 2024
1 parent e085c8c commit 69bbe4d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ We made many tests but risk zero do not exist, so if you see any bug, please rep
### Fixes

- Avoid error when removing obsolete flows (workaround using SF CLI if tooling api connection fails). Fixes [#662](https://github.com/hardisgroupcom/sfdx-hardis/issues/662)
- Improve Slack/Teams notifications display

### Documentation

Expand Down
6 changes: 3 additions & 3 deletions src/commands/hardis/org/diagnose/instanceupgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ export default class DiagnoseInstanceUpgrade extends SfCommand<any> {

// Get number of days before next major upgrade
const nextUpgradeDate = moment(orgInfo?.maintenanceNextUpgrade?.plannedStartTime);
const nextMajorUpgradeDateStr = nextUpgradeDate.format();
const nextMajorUpgradeDateStr = nextUpgradeDate.format("ll");
const today = moment();
const daysBeforeUpgrade = nextUpgradeDate.diff(today, 'days');
const daysBeforeUpgrade = today.diff(nextUpgradeDate, 'days');

// Manage notifications
const orgMarkdown = await getOrgMarkdown(flags['target-org']?.getConnection()?.instanceUrl);
const notifButtons = await getNotificationButtons();
let notifSeverity: NotifSeverity = 'log';
const notifText = `Salesforce instance ${instanceName} of ${orgMarkdown} will be upgraded on ${nextMajorUpgradeDateStr} (${daysBeforeUpgrade} days) to ${orgInfo?.maintenanceNextUpgrade?.name}`;
const notifText = `Salesforce instance *${instanceName}* of ${orgMarkdown} will be upgraded on ${nextMajorUpgradeDateStr} (*${daysBeforeUpgrade} days*) to ${orgInfo?.maintenanceNextUpgrade?.name}`;

// Change severity according to number of days
if (daysBeforeUpgrade <= 15) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/hardis/org/diagnose/releaseupdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co

// Fetch ReleaseUpdate records
const releaseUpdatesQuery =
`SELECT StepStage,Status,Category,DurableId,Title,DueDate,Description,Release,ReleaseLabel,ReleaseDate,ApiVersion, HasNewSteps,IsReleased,SupportsRevoke,DeveloperName ` +
`SELECT StepStage,Status,Category,Title,DueDate,Description,Release,ReleaseLabel,ReleaseDate,ApiVersion,DurableId,HasNewSteps,IsReleased,SupportsRevoke,DeveloperName ` +
`FROM ReleaseUpdate ` +
`WHERE StepStage IN ('Upcoming','OverDue') AND Status IN ('Invocable','Revocable','Nascent','Invoked','Info') AND DueDate >= LAST_N_DAYS:60 ` +
`ORDER BY DueDate DESC`;
Expand All @@ -94,7 +94,7 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
const notifText = `${this.releaseUpdatesRecords.length} Release Updates to check have been found in ${orgMarkdown}`
let notifDetailText = '';
for (const releaseUpdate of this.releaseUpdatesRecords) {
notifDetailText += `• ${releaseUpdate.Title} (${releaseUpdate.StepStage},${releaseUpdate.Status},${releaseUpdate.Category}), due for ${moment(releaseUpdate.DueDate).format("ll")}\n`;
notifDetailText += `• *${releaseUpdate.Title}* (${releaseUpdate.StepStage},${releaseUpdate.Status},${releaseUpdate.Category}), due for ${moment(releaseUpdate.DueDate).format("ll")}\n`;
}
const notifAttachments = [{ text: notifDetailText }];
// Post notif
Expand Down
4 changes: 2 additions & 2 deletions src/commands/hardis/org/diagnose/unusedusers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
if (users.length > 0) {
notifSeverity = this.returnActiveUsers ? 'log' : 'warning';
notifText = this.returnActiveUsers
? `${this.users.length} active users have logged in to ${orgMarkdown} within the last ${this.lastNdays} days.`
: `${this.users.length} active users have not logged in to ${orgMarkdown} within the last ${this.lastNdays} days.`;
? `*${this.users.length}* active users have logged in to ${orgMarkdown} within the last ${this.lastNdays} days.`
: `*${this.users.length}* active users have not logged in to ${orgMarkdown} within the last ${this.lastNdays} days.`;
attachments = [{ text: notifDetailText }];
}
const metrics = this.returnActiveUsers ? { ActiveUsers: this.users.length } : { UnusedUsers: this.users.length };
Expand Down
10 changes: 5 additions & 5 deletions src/commands/hardis/org/test/apex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
{
text: this.failingTestClasses
.map((failingTestClass) => {
return '• ' + failingTestClass.name + ' / ' + failingTestClass.error;
return '• *' + failingTestClass.name + '*: ' + failingTestClass.error;
})
.join('\n'),
},
Expand Down Expand Up @@ -215,13 +215,13 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
// Min coverage not reached
else if (coverageOrgWide < minCoverageOrgWide) {
this.notifSeverity = 'error';
this.statusMessage = `Test run coverage (org wide) ${coverageOrgWide}% should be > to ${minCoverageOrgWide}%`;
this.statusMessage = `Test run coverage (org wide) *${coverageOrgWide}%* should be > to ${minCoverageOrgWide}%`;
this.notifText = `${this.statusMessage} in ${this.orgMarkdown}`;
}
// We are good !
else {
this.notifSeverity = 'log';
this.statusMessage = `Test run coverage (org wide) ${coverageOrgWide}% is > to ${minCoverageOrgWide}%`;
this.statusMessage = `Test run coverage (org wide) *${coverageOrgWide}%* is > to ${minCoverageOrgWide}%`;
this.notifText = `${this.statusMessage} in ${this.orgMarkdown}`;
}
}
Expand Down Expand Up @@ -253,13 +253,13 @@ This command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.co
// Min coverage not reached
else if (coverageTestRun < minCoverageTestRun) {
this.notifSeverity = 'error';
this.statusMessage = `Test run coverage ${coverageTestRun}% should be > to ${minCoverageTestRun}%`;
this.statusMessage = `Test run coverage *${coverageTestRun}%* should be > to ${minCoverageTestRun}%`;
this.notifText = `${this.statusMessage} in ${this.orgMarkdown}`;
}
// We are good !
else {
this.notifSeverity = 'log';
this.statusMessage = `Test run coverage ${coverageTestRun}% is > to ${minCoverageTestRun}%`;
this.statusMessage = `Test run coverage *${coverageTestRun}%* is > to ${minCoverageTestRun}%`;
this.notifText = `${this.statusMessage} in ${this.orgMarkdown}`;
}
}
Expand Down

0 comments on commit 69bbe4d

Please sign in to comment.