mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
Refactor ServerMonitorCriteria class to improve code readability and remove redundant code
This commit is contained in:
parent
8ebcb1b659
commit
37a13ce853
@ -162,48 +162,8 @@ export default class ServerMonitorCriteria {
|
||||
!(input.dataToProcess as ServerMonitorResponse)
|
||||
.onlyCheckRequestReceivedAt
|
||||
) {
|
||||
const thresholdProcessName: string = threshold
|
||||
.toString()
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
|
||||
if (input.criteriaFilter.filterType === FilterType.IsExecuting) {
|
||||
const processNames: Array<string> =
|
||||
(
|
||||
input.dataToProcess as ServerMonitorResponse
|
||||
)?.processes?.map((item: ServerProcess) => {
|
||||
return item.name.trim().toLowerCase();
|
||||
}) || [];
|
||||
|
||||
if (processNames.includes(thresholdProcessName)) {
|
||||
return `Process ${threshold} is executing.`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (input.criteriaFilter.filterType === FilterType.IsNotExecuting) {
|
||||
const processNames: Array<string> =
|
||||
(
|
||||
input.dataToProcess as ServerMonitorResponse
|
||||
)?.processes?.map((item: ServerProcess) => {
|
||||
return item.name.trim().toLowerCase();
|
||||
}) || [];
|
||||
|
||||
if (!processNames.includes(thresholdProcessName)) {
|
||||
return `Process ${threshold} is not executing.`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
input.criteriaFilter.checkOn === CheckOn.ServerProcessName &&
|
||||
threshold &&
|
||||
!(input.dataToProcess as ServerMonitorResponse)
|
||||
.onlyCheckRequestReceivedAt
|
||||
) {
|
||||
debugger;
|
||||
const thresholdProcessName: string = threshold
|
||||
.toString()
|
||||
.trim()
|
||||
|
Loading…
Reference in New Issue
Block a user