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

Deduplicate embedded ansible notifications #17394

Merged

Conversation

carbonin
Copy link
Member

@carbonin carbonin commented May 8, 2018

This PR changes the Embedded Ansible role notification behavior so that a new notification is only created when either there is no existing one for that server or the existing one has been read.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1486695

return
end

create_notification(notification_type) unless notifications.any? do |n|
Copy link
Member

Choose a reason for hiding this comment

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

We can probably handle the if notifications.empty? case here. notifications.any? should be nearly as fast as notifications.empty? or the speed difference should not warrant the mental cost of an early return and extra conditional. Of course, I assume it would work by just removing the entire if notifications.empty? condition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately [].any? always returns false, so we can't remove the empty? check. I had a version of this where I combined the conditions, but this felt easier to read.

Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, lol. I inverted my truth table.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this one took some work to make it even a bit readable. Still looking for improvements if you've got anything.

I could also add comments if it would be helpful.

carbonin added 3 commits May 9, 2018 12:25
This commit changes the notification behavior so that a new notification
is only created when either there is no existing one for that server
or the existing one has been read.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1486695
@carbonin carbonin force-pushed the dedup_embedded_ansible_notifications branch from 48f6618 to 92884fe Compare May 9, 2018 16:29
@miq-bot
Copy link
Member

miq-bot commented May 9, 2018

Checked commits carbonin/manageiq@a6b0434~...92884fe with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
4 files checked, 0 offenses detected
Everything looks fine. 🍰

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

Wow ❤️ 💙 🥇

This is so simple now. :shipit: :shipit: :shipit:

@jrafanie jrafanie merged commit 9c36ec8 into ManageIQ:master May 9, 2018
@jrafanie jrafanie added this to the Sprint 86 Ending May 21, 2018 milestone May 9, 2018
@jrafanie
Copy link
Member

jrafanie commented May 9, 2018

@carbonin add your labels, is it only gaprindashvili/yes?

@carbonin
Copy link
Member Author

carbonin commented May 9, 2018

@jrafanie the bug doesn't have any backport flags, but I guess this can go back

@carbonin carbonin deleted the dedup_embedded_ansible_notifications branch August 16, 2019 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants