-
Notifications
You must be signed in to change notification settings - Fork 151
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
[BUGFIX] Fix computed labels #129
Conversation
Codecov Report
@@ Coverage Diff @@
## master #129 +/- ##
======================================
Coverage 45.1% 45.1%
======================================
Files 38 38
Lines 2361 2361
======================================
Hits 1065 1065
Misses 1296 1296 Continue to review full report at Codecov.
|
}, | ||
computed: { | ||
alertLabelsService: function () { | ||
return this.filterBy(this.globalAlerts, 'service'); | ||
return new Set(this.globalAlerts |
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 better to define this process to a method
and call it from computed property.
So maintenance will be easily.
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 previously wrote it as my own method, but I think that even though it's a few more lines in the computed properly itself, it's much more readable and more maintainable in this format
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.
Like this
methods: {
filterByService: function() {
return new Set(
this.globalAlerts
.filter(x => x.status.state == 'active')
.filter(x => x.labels.service)
.map(x => x.labels.service)
.sort()
)
},
filterByProject: function() {
return new Set(
this.globalAlerts
.filter(x => x.status.state == 'active')
.filter(x => x.labels.project)
.map(x => x.labels.project)
.sort()
)
},
filterByAlertName: function() {
return new Set(
this.globalAlerts
.filter(x => x.status.state == 'active')
.filter(x => x.labels.alertname)
.map(x => x.labels.alertname)
.sort()
)
}
},
computed: {
alertLabelsService: function() {
return this.filterByService
},
alertLabelsProject: function() {
return this.filterByProject
},
alertLabelsRule: function() {
return this.filterByAlertName
},
silenceLabelsService: function() {
return this.filterByService
},
silenceLabelsProject: function() {
return this.filterByProject
},
}
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'm sorry. This code was wrong.
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.
LGTM
Removes some custom logic that was likely wrong and simplify using native javascript filter and map functions