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

Use settings for purging records #12552

Merged
merged 1 commit into from
Nov 22, 2016
Merged

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Nov 10, 2016

Use settings to purge records

I did need to remove 2 specs.
They were testing when settings has no value.
But the new way we handle settings, we put the default value into settings.yaml, so that no longer made sense.

/cc @yrudman FYI

@@ -4,14 +4,14 @@ module DriftState::Purging

module ClassMethods
def purge_mode_and_value
value = VMDB::Config.new("vmdb").config.fetch_path(:drift_states, :history, :keep_drift_states)
value = ::Settings.fetch_path(:drift_states, :history, :keep_drift_states)
Copy link
Member

Choose a reason for hiding this comment

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

Prefer dot notation over fetch path

mode = (value.nil? || value.number_with_method?) ? :date : :remaining
value = (value || 6.months).to_i_with_method.seconds.ago.utc if mode == :date
return mode, value
end

def purge_window_size
VMDB::Config.new("vmdb").config.fetch_path(:drift_states, :history, :purge_window_size) || 10000
::Settings.fetch_path(:drift_states, :history, :purge_window_size) || 10_000
Copy link
Member

Choose a reason for hiding this comment

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

No need for defaultsin the source anymore...please move the default to settngs.yml directly.

@@ -1,6 +1,6 @@
module Metric::Purging
def self.purge_date(type)
value = VMDB::Config.new("vmdb").config.fetch_path(:performance, :history, type.to_sym)
value = ::Settings.fetch_path(:performance, :history, type.to_sym)
Copy link
Member

Choose a reason for hiding this comment

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

For this one you would do something like value = ::Settings.performance.history[type] (No need even for the to_sym anymore)

@kbrock
Copy link
Member Author

kbrock commented Nov 14, 2016

Updated:

  • Using defaults from the file
  • Double checked the values in the file that all were present (did change 2)

Noticed:

  • vmdb_metric/purging.rb#purge_date is odd that it uses Fixnum rather than number_with_method?
  • "convert this setting that is number of days ago or remaining" is implemented a few times. Other areas do not use remaining, but do this type of conversion.

@Fryguy
Copy link
Member

Fryguy commented Nov 16, 2016

LGTM 👍

Just needs to go 💚

@miq-bot
Copy link
Member

miq-bot commented Nov 21, 2016

This pull request is not mergeable. Please rebase and repush.

no longer need to test with missing config values since 
they are in the default settings.yml
@miq-bot
Copy link
Member

miq-bot commented Nov 21, 2016

Checked commit kbrock@08f4f84 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
6 files checked, 0 offenses detected
Everything looks good. ⭐

@yrudman
Copy link
Contributor

yrudman commented Nov 21, 2016

👍 looks good
@Fryguy ready for you

@kbrock
Copy link
Member Author

kbrock commented Nov 22, 2016

thanks @yrudman -- I changed a few things and appreciate the second look

@kbrock
Copy link
Member Author

kbrock commented Nov 22, 2016

@Fryguy this is green. anything else?

@Fryguy Fryguy merged commit ed2c1ec into ManageIQ:master Nov 22, 2016
@Fryguy Fryguy added this to the Sprint 50 Ending Dec 5, 2016 milestone Nov 22, 2016
@simaishi simaishi added euwe/no and removed euwe/yes labels Jan 19, 2017
@kbrock kbrock deleted the purge_settings branch November 30, 2018 21:10
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.

6 participants