Class: Soba::Services::ClosedIssueWindowCleaner
- Inherits:
-
Object
- Object
- Soba::Services::ClosedIssueWindowCleaner
- Defined in:
- lib/soba/services/closed_issue_window_cleaner.rb
Instance Attribute Summary collapse
-
#github_client ⇒ Object
readonly
Returns the value of attribute github_client.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#tmux_client ⇒ Object
readonly
Returns the value of attribute tmux_client.
Instance Method Summary collapse
- #clean(session_name) ⇒ Object
-
#initialize(github_client:, tmux_client:, logger:) ⇒ ClosedIssueWindowCleaner
constructor
A new instance of ClosedIssueWindowCleaner.
- #should_clean? ⇒ Boolean
Constructor Details
#initialize(github_client:, tmux_client:, logger:) ⇒ ClosedIssueWindowCleaner
Returns a new instance of ClosedIssueWindowCleaner.
8 9 10 11 12 13 14 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 8 def initialize(github_client:, tmux_client:, logger:) @github_client = github_client @tmux_client = tmux_client @logger = logger @last_cleanup_time = nil @repository = nil end |
Instance Attribute Details
#github_client ⇒ Object (readonly)
Returns the value of attribute github_client.
6 7 8 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 6 def github_client @github_client end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 6 def logger @logger end |
#tmux_client ⇒ Object (readonly)
Returns the value of attribute tmux_client.
6 7 8 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 6 def tmux_client @tmux_client end |
Instance Method Details
#clean(session_name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 16 def clean(session_name) logger.debug("Cleaning up windows for closed issues in session: #{session_name}") begin closed_issues = fetch_closed_issues if closed_issues.empty? logger.debug('No closed issues found') return end logger.debug("Found #{closed_issues.size} closed issues") windows = list_tmux_windows(session_name) return if windows.nil? removed_count = 0 closed_issues.each do |issue| window_name = "issue-#{issue.number}" if windows.include?(window_name) if remove_window(session_name, window_name, issue) removed_count += 1 end end end logger.debug("Cleanup completed for #{session_name}: removed #{removed_count} windows") rescue StandardError => e logger.error("Unexpected error during cleanup: #{e.}") end end |
#should_clean? ⇒ Boolean
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/soba/services/closed_issue_window_cleaner.rb', line 47 def should_clean? return false unless config.workflow.closed_issue_cleanup_enabled if @last_cleanup_time.nil? @last_cleanup_time = Time.now return true end time_since_last = Time.now - @last_cleanup_time if time_since_last >= config.workflow.closed_issue_cleanup_interval @last_cleanup_time = Time.now return true end false end |