Created a script to enable/disable a list of alerts#72
Conversation
Cloned the 'update_alerts.py' example to create a script that would take a list of alerts, and flip their enabled status. A customer had requested the ability to selectively enable / disable a list of alerts on a schedule, so I created this so they could run it on a cronjob. Will also add this as a FR.
| if alert['enabled'] == True: | ||
| alert['enabled'] = False | ||
| else: | ||
| alert['enabled'] = True |
There was a problem hiding this comment.
Probably this is because copy-pasting old code. But this could be improved by a single alert['enabled'] = not alert['enabled']
@davideschiera Should we step by step improve this repo code when adding new code?
There was a problem hiding this comment.
The one-liner seems reasonable (especially in this context, as long as you can "read" the line and it sounds clear enough, then it's all good).
In terms of refactoring, I think it's a good idea. I actually missed this one when I reviewed the PR last week, sorry about that.
Feel free to file PRs to clean up the code base, we can also discuss offline about the major points to solve. Thanks!!
There was a problem hiding this comment.
@davideschiera If not in a hurry, you can let another pair of 👀 to take a look at the PR 😄 By now, we can live without this one-liner.
Don't have the desired time to attend this repo, but 👍 to offline discussion.
There was a problem hiding this comment.
Agreed. Thanks for bringing it up!
Cloned the 'update_alerts.py' example to create a script that would take a list of alerts, and flip their enabled status. A customer had requested the ability to selectively enable / disable a list of alerts on a schedule, so I created this so they could run it on a cronjob. Will also add this as a FR.