-
-
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
Conversation
…ount of add'l children
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.
Thank you for your PR!
I have left some inline comments
server/model/monitor.js
Outdated
@@ -383,6 +383,8 @@ class Monitor extends BeanModel { | |||
bean.msg = "Monitor under maintenance"; | |||
bean.status = MAINTENANCE; | |||
} else if (this.type === "group") { | |||
let failChild = ""; |
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.
nit:
please don't hamming code variable names here.
I think downChildrenName
and downChildrenCount
are better names
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.
I'll go with downChildName and failureCount
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.
names are different despite close in meaning => don't think this is good for long-term maintence
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.
Your petulant complaints have made contributing to this project far more trouble than it is worth. Good day, sir.
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.
I think we are not on the same page what the job as a maintainer is. I see it as making sure that the project can and will move in the right direction.
This does mean that the primary job is to make sure that the code stays maintainable and readable.
The job is not to blindly accept any contribution.
What might be a source of miscommunication is my usage of nit:
comments. These comments can be addressed, but does not have to.
server/model/monitor.js
Outdated
@@ -383,6 +383,8 @@ class Monitor extends BeanModel { | |||
bean.msg = "Monitor under maintenance"; | |||
bean.status = MAINTENANCE; | |||
} else if (this.type === "group") { | |||
let failChild = ""; |
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.
I think it would be better to collect the DOWN
-children in a list instead of doing this double accounting (last name + count).
This would allow adding this to the logging output, and I think the code might look better.
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.
Even including the count was beyond the scope of the original request. It's simple, doesn't use any extra memory, and makes the message more informative. I'll stick with what I have.
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.
I am not convinced that the extra memory of a few child-names will matter for overall performance/memory consumption.
Yes, my approach does consume a bit more memory, but assuming reasonably long names and a reasonable ammount of monitors per group this likely won't be a problem.
I do think adding a separate mechanism for accounting for the failed number is sort of a footgun => I would prefer a list for tracking this ^^
@@ -1526,6 +1543,23 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
* @returns {Promise<string>} Name of this monitor's parent | |
* @returns {Promise<string>} Name of this monitor's parent or '' if no parent exists |
Co-authored-by: Frank Elsinga <[email protected]>
Co-authored-by: Frank Elsinga <[email protected]>
suggestion accepted Co-authored-by: Frank Elsinga <[email protected]>
let parentName = await this.getParentName(); | ||
groupText = ` under group '${parentName}'`; |
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.
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.
I don't think the comparison with getPathName
is fair as said function does do a lot more.
let parentName = await this.getParentName(); | |
groupText = ` under group '${parentName}'`; | |
let parent = await Monitor.getParent(this.id); | |
groupText = ` under group '${parent.name}'`; |
/** | ||
* Gets Parent name | ||
* @returns {Promise<string>} Name of this monitor's parent | ||
*/ | ||
async getParentName() { | ||
if (this.parent === null) { | ||
return ""; | ||
} | ||
|
||
let parent = await Monitor.getParent(this.id); | ||
return parent.name; | ||
} | ||
|
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.
Continiuation of the suggested changes in https://github.com/louislam/uptime-kuma/pull/4371/files#r1452821597
/** | |
* Gets Parent name | |
* @returns {Promise<string>} Name of this monitor's parent | |
*/ | |
async getParentName() { | |
if (this.parent === null) { | |
return ""; | |
} | |
let parent = await Monitor.getParent(this.id); | |
return parent.name; | |
} |
let downChildName = ""; | ||
let failureCount = 0; |
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 using failureCount
let downChildName = ""; | |
let failureCount = 0; | |
let downChildNames = []; |
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
downChildName = child.name; | |
downChildNames.push(child.name); |
} 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 comment
The reason will be displayed to describe this comment to others. Learn more.
downChildName = child.name; | |
downChildNames.push(child.name); |
} | ||
if (lastBeat.status === DOWN) { | ||
failureCount++; |
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.
} | |
if (lastBeat.status === DOWN) { | |
failureCount++; |
if (failureCount <= 1) { | ||
bean.msg = `Child '${downChildName}' inaccessible`; | ||
} else { | ||
bean.msg = `Child '${downChildName}' and ${failureCount - 1} others inaccessible`; | ||
} |
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.
if (failureCount <= 1) { | |
bean.msg = `Child '${downChildName}' inaccessible`; | |
} else { | |
bean.msg = `Child '${downChildName}' and ${failureCount - 1} others inaccessible`; | |
} | |
if (downChildNames.lenght === 1) { | |
bean.msg = `Child '${downChildName[0]}' inaccessible`; | |
} else { | |
bean.msg = `Child '${downChildNames[0]}' and ${downChildNames.lengh - 1} others inaccessible`; | |
} |
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.
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Collect a list of names, just to get the first name from the list.
first name and the lenght of the list.
you've misspelled length
Good catch. fixed it
I'll just keep my own private fork of this project, and shape it to my own needs
That is fine by us.
Forking a project doesn’t have to be a bad thing. Being able to copy and modify projects is one of the best things about open source1
People like you make open source worse than working for a corporation with bad management.
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
hi all, looks like some trouble with code review here. would you all like me to pick up this PR? I would really like this feature and will donate some time to it. |
@tylerjwatson I am going to close this PR as I don't see @homeautomaton contributing to this PR further as they stated:
|
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Fixes #3278
Type of change
Please delete any options that are not relevant.
Checklist
Screenshots (if any)
Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.