Skip to content
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

Merged
merged 1 commit into from
Mar 1, 2019
Merged

[BUGFIX] Fix computed labels #129

merged 1 commit into from
Mar 1, 2019

Conversation

kfdm
Copy link
Collaborator

@kfdm kfdm commented Feb 28, 2019

Removes some custom logic that was likely wrong and simplify using native javascript filter and map functions

@codecov-io
Copy link

Codecov Report

Merging #129 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d5225e...13a4a3c. Read the comment docs.

@kfdm kfdm requested review from Asuforce and matsumana March 1, 2019 03:23
@kfdm kfdm marked this pull request as ready for review March 1, 2019 03:23
},
computed: {
alertLabelsService: function () {
return this.filterBy(this.globalAlerts, 'service');
return new Set(this.globalAlerts
Copy link
Member

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.

Copy link
Collaborator Author

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

Copy link
Member

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
    },
}

Copy link
Member

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.

Copy link
Member

@Asuforce Asuforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kfdm kfdm merged commit ca91456 into line:master Mar 1, 2019
@kfdm kfdm deleted the alert-filter-bugfix branch March 1, 2019 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants