Class: Judges::Trim
Overview
Trim.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
-
#initialize(loog) ⇒ Trim
constructor
A new instance of Trim.
- #run(opts, args) ⇒ Object
Constructor Details
#initialize(loog) ⇒ Trim
Returns a new instance of Trim.
32 33 34 |
# File 'lib/judges/commands/trim.rb', line 32 def initialize(loog) @loog = loog end |
Instance Method Details
#run(opts, args) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/judges/commands/trim.rb', line 36 def run(opts, args) raise 'Exactly one argument required' unless args.size == 1 impex = Judges::Impex.new(@loog, args[0]) fb = impex.import day = Time.now - (opts['days'].to_i * 60 * 60 * 24) p "(lt time #{day.utc.iso8601})" deleted = fb.query("(lt time #{day.utc.iso8601})").delete! @loog.info("#{deleted} facts deleted because they are too old") impex.export(fb) end |