-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[groups] Put child's name in the notification, also added count of additional children #4371
Changes from all commits
78ef79f
4e9afcf
59d5148
a1fbc6f
63a41cf
d379157
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -383,6 +383,8 @@ class Monitor extends BeanModel { | |||||||||||||||||||||||||
bean.msg = "Monitor under maintenance"; | ||||||||||||||||||||||||||
bean.status = MAINTENANCE; | ||||||||||||||||||||||||||
} else if (this.type === "group") { | ||||||||||||||||||||||||||
let downChildName = ""; | ||||||||||||||||||||||||||
let failureCount = 0; | ||||||||||||||||||||||||||
const children = await Monitor.getChildren(this.id); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (children.length > 0) { | ||||||||||||||||||||||||||
|
@@ -395,19 +397,28 @@ class Monitor extends BeanModel { | |||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
const lastBeat = await Monitor.getPreviousHeartbeat(child.id); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Only change state if the monitor is in worse conditions then the ones before | ||||||||||||||||||||||||||
// Only change state if the monitor is in worse conditions than the ones before | ||||||||||||||||||||||||||
// lastBeat.status could be null | ||||||||||||||||||||||||||
if (!lastBeat) { | ||||||||||||||||||||||||||
bean.status = PENDING; | ||||||||||||||||||||||||||
} else if (bean.status === UP && (lastBeat.status === PENDING || lastBeat.status === DOWN)) { | ||||||||||||||||||||||||||
bean.status = lastBeat.status; | ||||||||||||||||||||||||||
downChildName = child.name; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
} else if (bean.status === PENDING && lastBeat.status === DOWN) { | ||||||||||||||||||||||||||
bean.status = lastBeat.status; | ||||||||||||||||||||||||||
downChildName = child.name; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
if (lastBeat.status === DOWN) { | ||||||||||||||||||||||||||
failureCount++; | ||||||||||||||||||||||||||
Comment on lines
+410
to
+412
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (bean.status !== UP) { | ||||||||||||||||||||||||||
bean.msg = "Child inaccessible"; | ||||||||||||||||||||||||||
if (failureCount <= 1) { | ||||||||||||||||||||||||||
bean.msg = `Child '${downChildName}' inaccessible`; | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
bean.msg = `Child '${downChildName}' and ${failureCount - 1} others inaccessible`; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
Comment on lines
+417
to
+421
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nothing short of ridiculous. Collect a list of names, just to get the first name from the list. And you've misspelled length. Your code wouldn't even work. I'll just keep my own private fork of this project, and shape it to my own needs. I have many enhancements in mind, and working on this trivial already-existing issue was just my way of testing the waters to see if it is worth contributing to the project. People like you make open source worse than working for a corporation with bad management. Good riddance. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @louislam Do you have an opinion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
first name and the lenght of the list.
Good catch. fixed it
That is fine by us.
Sorry that you feel this way. If there is something concrete that I can change in the way I review work, that would be appreciated (I am not even a junior dev in terms of job experience right now) Footnotes |
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
// Set status pending if group is empty | ||||||||||||||||||||||||||
|
@@ -971,7 +982,13 @@ class Monitor extends BeanModel { | |||||||||||||||||||||||||
} else if (bean.status === MAINTENANCE) { | ||||||||||||||||||||||||||
log.warn("monitor", `Monitor #${this.id} '${this.name}': Under Maintenance | Type: ${this.type}`); | ||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||
log.warn("monitor", `Monitor #${this.id} '${this.name}': Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type} | Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`); | ||||||||||||||||||||||||||
let groupText = ""; | ||||||||||||||||||||||||||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
if (this.type !== "group" && this.parent !== "") { | ||||||||||||||||||||||||||
let parentName = await this.getParentName(); | ||||||||||||||||||||||||||
CommanderStorm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
groupText = ` under group '${parentName}'`; | ||||||||||||||||||||||||||
Comment on lines
+987
to
+988
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re https://github.com/louislam/uptime-kuma/pull/4371/files#r1452660704 (I can't add the second line to the suggestion) I did forget to add the second line to the code suggestion.
Suggested change
|
||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
log.warn("monitor", `Monitor #${this.id} '${this.name}'${groupText}: Failing: ${bean.msg} | Interval: ${beatInterval} seconds | Type: ${this.type} | Down Count: ${bean.downCount} | Resend Interval: ${this.resendInterval}`); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
// Calculate uptime | ||||||||||||||||||||||||||
|
@@ -1526,6 +1543,19 @@ class Monitor extends BeanModel { | |||||||||||||||||||||||||
]); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Gets Parent name | ||||||||||||||||||||||||||
* @returns {Promise<string>} Name of this monitor's parent | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
async getParentName() { | ||||||||||||||||||||||||||
if (this.parent === null) { | ||||||||||||||||||||||||||
return ""; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
let parent = await Monitor.getParent(this.id); | ||||||||||||||||||||||||||
return parent.name; | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+1546
to
+1558
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Continiuation of the suggested changes in https://github.com/louislam/uptime-kuma/pull/4371/files#r1452821597
Suggested change
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* Gets Full Path-Name (Groups and Name) | ||||||||||||||||||||||||||
* @returns {Promise<string>} Full path name of this monitor | ||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Continuation of #4371 (comment)
I can only suggest refactorings for lines you changed => this is why this suggestion is split into multiple parts
My consearn is mostly around future maintenence effort and if this introduces bugs like the faulty (not taking into account
PENDING
) accounting usingfailureCount