{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/208318808","pull_request_review_id":144103849,"id":208318808,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwODMxODgwOA==","diff_hunk":"@@ -59,11 +59,19 @@ def self.event_groups\n \n   def self.group_and_level(event_type)\n     level = :detail # the level is detail as default\n-    group, _ = event_groups.find do |_k, value|\n-      GROUP_LEVELS.detect { |lvl| value[lvl]&.include?(event_type) }.tap do |level_found|\n-        level = level_found if level_found\n-      end\n-    end\n+    egroups = event_groups\n+\n+    group = egroups.find do |_, value|\n+      GROUP_LEVELS\n+        .find { |lvl| value[lvl]&.select { |typ| typ.kind_of?(String) }&.include?(event_type) }\n+        .tap { |level_found| level = level_found || level }\n+    end&.first\n+\n+    group ||= egroups.find do |_, value|\n+      GROUP_LEVELS\n+        .find { |lvl| value[lvl]&.select { |typ| typ.kind_of?(Regexp) }&.find { |regex| regex.match(event_type) } }","path":"app/models/event_stream.rb","position":19,"original_position":19,"commit_id":"9b005ee62da54b42cb6b3c65f798c74bfd5086c2","original_commit_id":"9b005ee62da54b42cb6b3c65f798c74bfd5086c2","user":{"login":"Fryguy","id":52120,"node_id":"MDQ6VXNlcjUyMTIw","avatar_url":"https://avatars3.githubusercontent.com/u/52120?v=4","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"body":"Oh wow you are right!  I didn't realize `.match?` was Ruby 2.4 only,  So yeah, leave it.","created_at":"2018-08-07T17:31:10Z","updated_at":"2018-08-07T17:31:10Z","html_url":"https://github.com/ManageIQ/manageiq/pull/17772#discussion_r208318808","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/208318808"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/17772#discussion_r208318808"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772"}},"in_reply_to_id":208315694},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772","id":204656787,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0NjU2Nzg3","html_url":"https://github.com/ManageIQ/manageiq/pull/17772","diff_url":"https://github.com/ManageIQ/manageiq/pull/17772.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/17772.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/17772","number":17772,"state":"open","locked":false,"title":"Allow mapping event types to groups using regexes","user":{"login":"tadeboro","id":70951,"node_id":"MDQ6VXNlcjcwOTUx","avatar_url":"https://avatars3.githubusercontent.com/u/70951?v=4","gravatar_id":"","url":"https://api.github.com/users/tadeboro","html_url":"https://github.com/tadeboro","followers_url":"https://api.github.com/users/tadeboro/followers","following_url":"https://api.github.com/users/tadeboro/following{/other_user}","gists_url":"https://api.github.com/users/tadeboro/gists{/gist_id}","starred_url":"https://api.github.com/users/tadeboro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadeboro/subscriptions","organizations_url":"https://api.github.com/users/tadeboro/orgs","repos_url":"https://api.github.com/users/tadeboro/repos","events_url":"https://api.github.com/users/tadeboro/events{/privacy}","received_events_url":"https://api.github.com/users/tadeboro/received_events","type":"User","site_admin":false},"body":"Up until now, in order to associate an event type with an event group, we needed to spell out events full name in settings file under appropriate event group category and level.\r\n\r\nSome of the providers have hundreds of event types, which makes filling all this information in tedious and error prone. Not to mention that settings file is now one giant pile of event types.\r\n\r\nIn order to make process of registering event types scale a bit better, this commit adds support for registering a class of event types that match specified regular expressions. Simple example:\r\n\r\n    :ems:\r\n      :ems_dummy:\r\n        :event_handling:\r\n          :event_groups:\r\n            :addition:\r\n              :critical:\r\n              - dummy_event01_add\r\n              - dummy_event02_add\r\n              :detail:\r\n              - dummy_event03_add\r\n              - dummy_event04_add\r\n              ...\r\n              - dummy_event70_add\r\n              - dm_event_create\r\n\r\nThis can now be written as\r\n\r\n    :ems:\r\n      :ems_dummy:\r\n        :event_handling:\r\n          :event_groups:\r\n            :addition:\r\n              :critical:\r\n              - dummy_event01_add\r\n              - dummy_event02_add\r\n              :detail:\r\n              - dm_event_create\r\n              :detail_regex:\r\n              - ^dummy_[0-9]{2}_add$\r\n\r\nRegular expression support has been added to all levels, so if there exists a level `:lvl`, then `:lvl_regex` is also available.\r\n\r\nWe took a great deal of care not to break existing code, so non-regex event type mappings take precedence over regular expression matches. For example, in our sample above, `dummy_event_02_add` gets assigned critical level despite also matching detail regex.\r\n\r\nNote that if sets of event types that are matched by regular expressions are not disjoint, then there will be multiple valid event type mappings. In this case, event types that match more than one\r\ngroup and/or level get assigned an arbitrary one.\r\n\r\n@miq-bot assign @gtanzillo \r\n\r\n/cc @miha-plesko @agrare @gberginc ","created_at":"2018-07-29T19:13:16Z","updated_at":"2018-08-07T17:31:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90537604ae0cb894f24ed3f35675338736d72f93","assignee":{"login":"Fryguy","id":52120,"node_id":"MDQ6VXNlcjUyMTIw","avatar_url":"https://avatars3.githubusercontent.com/u/52120?v=4","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false},"assignees":[{"login":"Fryguy","id":52120,"node_id":"MDQ6VXNlcjUyMTIw","avatar_url":"https://avatars3.githubusercontent.com/u/52120?v=4","gravatar_id":"","url":"https://api.github.com/users/Fryguy","html_url":"https://github.com/Fryguy","followers_url":"https://api.github.com/users/Fryguy/followers","following_url":"https://api.github.com/users/Fryguy/following{/other_user}","gists_url":"https://api.github.com/users/Fryguy/gists{/gist_id}","starred_url":"https://api.github.com/users/Fryguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fryguy/subscriptions","organizations_url":"https://api.github.com/users/Fryguy/orgs","repos_url":"https://api.github.com/users/Fryguy/repos","events_url":"https://api.github.com/users/Fryguy/events{/privacy}","received_events_url":"https://api.github.com/users/Fryguy/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":106615678,"node_id":"MDU6TGFiZWwxMDY2MTU2Nzg=","url":"https://api.github.com/repos/ManageIQ/manageiq/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/17772/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/9b005ee62da54b42cb6b3c65f798c74bfd5086c2","head":{"label":"xlab-si:event-type-regex","ref":"event-type-regex","sha":"9b005ee62da54b42cb6b3c65f798c74bfd5086c2","user":{"login":"xlab-si","id":17640165,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQwMTY1","avatar_url":"https://avatars2.githubusercontent.com/u/17640165?v=4","gravatar_id":"","url":"https://api.github.com/users/xlab-si","html_url":"https://github.com/xlab-si","followers_url":"https://api.github.com/users/xlab-si/followers","following_url":"https://api.github.com/users/xlab-si/following{/other_user}","gists_url":"https://api.github.com/users/xlab-si/gists{/gist_id}","starred_url":"https://api.github.com/users/xlab-si/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xlab-si/subscriptions","organizations_url":"https://api.github.com/users/xlab-si/orgs","repos_url":"https://api.github.com/users/xlab-si/repos","events_url":"https://api.github.com/users/xlab-si/events{/privacy}","received_events_url":"https://api.github.com/users/xlab-si/received_events","type":"Organization","site_admin":false},"repo":{"id":53126087,"node_id":"MDEwOlJlcG9zaXRvcnk1MzEyNjA4Nw==","name":"manageiq","full_name":"xlab-si/manageiq","owner":{"login":"xlab-si","id":17640165,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3NjQwMTY1","avatar_url":"https://avatars2.githubusercontent.com/u/17640165?v=4","gravatar_id":"","url":"https://api.github.com/users/xlab-si","html_url":"https://github.com/xlab-si","followers_url":"https://api.github.com/users/xlab-si/followers","following_url":"https://api.github.com/users/xlab-si/following{/other_user}","gists_url":"https://api.github.com/users/xlab-si/gists{/gist_id}","starred_url":"https://api.github.com/users/xlab-si/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xlab-si/subscriptions","organizations_url":"https://api.github.com/users/xlab-si/orgs","repos_url":"https://api.github.com/users/xlab-si/repos","events_url":"https://api.github.com/users/xlab-si/events{/privacy}","received_events_url":"https://api.github.com/users/xlab-si/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xlab-si/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/xlab-si/manageiq","forks_url":"https://api.github.com/repos/xlab-si/manageiq/forks","keys_url":"https://api.github.com/repos/xlab-si/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xlab-si/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xlab-si/manageiq/teams","hooks_url":"https://api.github.com/repos/xlab-si/manageiq/hooks","issue_events_url":"https://api.github.com/repos/xlab-si/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/xlab-si/manageiq/events","assignees_url":"https://api.github.com/repos/xlab-si/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/xlab-si/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/xlab-si/manageiq/tags","blobs_url":"https://api.github.com/repos/xlab-si/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xlab-si/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xlab-si/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/xlab-si/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xlab-si/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/xlab-si/manageiq/languages","stargazers_url":"https://api.github.com/repos/xlab-si/manageiq/stargazers","contributors_url":"https://api.github.com/repos/xlab-si/manageiq/contributors","subscribers_url":"https://api.github.com/repos/xlab-si/manageiq/subscribers","subscription_url":"https://api.github.com/repos/xlab-si/manageiq/subscription","commits_url":"https://api.github.com/repos/xlab-si/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/xlab-si/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/xlab-si/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/xlab-si/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/xlab-si/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/xlab-si/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xlab-si/manageiq/merges","archive_url":"https://api.github.com/repos/xlab-si/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xlab-si/manageiq/downloads","issues_url":"https://api.github.com/repos/xlab-si/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/xlab-si/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/xlab-si/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/xlab-si/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xlab-si/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/xlab-si/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/xlab-si/manageiq/deployments","created_at":"2016-03-04T10:03:29Z","updated_at":"2018-08-06T16:28:51Z","pushed_at":"2018-08-07T14:05:07Z","git_url":"git://github.com/xlab-si/manageiq.git","ssh_url":"git@github.com:xlab-si/manageiq.git","clone_url":"https://github.com/xlab-si/manageiq.git","svn_url":"https://github.com/xlab-si/manageiq","homepage":"manageiq.org","size":210981,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"c40c68d3fa242f0eecaf63afbd79f5362f0f7d74","user":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"node_id":"MDEwOlJlcG9zaXRvcnkyMDc4OTc1Nw==","name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExMjU1NzU=","avatar_url":"https://avatars0.githubusercontent.com/u/1125575?v=4","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Open-Source Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq/deployments","created_at":"2014-06-13T02:31:26Z","updated_at":"2018-08-07T15:39:01Z","pushed_at":"2018-08-07T16:24:12Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":255372,"stargazers_count":685,"watchers_count":685,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":653,"mirror_url":null,"archived":false,"open_issues_count":600,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":653,"open_issues":600,"watchers":685,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/17772"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/17772"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/17772/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/17772/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/9b005ee62da54b42cb6b3c65f798c74bfd5086c2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"Fryguy"}}