Class: CodeSunset::RemovalPromptBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/code_sunset/removal_prompt_builder.rb

Defined Under Namespace

Classes: SearchMatch

Constant Summary collapse

SEARCH_DIRECTORIES =
%w[app config lib db test spec].freeze
EXCLUDED_DIRECTORY_NAMES =
%w[log tmp storage node_modules .git].freeze
EXCLUDED_PATH_FRAGMENTS =
["vendor/bundle"].freeze
MATCH_LIMIT =
20
RECENT_EVENT_LIMIT =
5
PREVIEW_LIMIT =
180

Instance Method Summary collapse

Constructor Details

#initialize(feature:, snapshot:, filters:, top_orgs:, top_users:, request_paths:, job_usage:, recent_events:, recent_events_total_count:, usage_series:, root: Rails.root) ⇒ RemovalPromptBuilder

Returns a new instance of RemovalPromptBuilder.



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/code_sunset/removal_prompt_builder.rb', line 25

def initialize(feature:, snapshot:, filters:, top_orgs:, top_users:, request_paths:, job_usage:, recent_events:, recent_events_total_count:, usage_series:, root: Rails.root)
  @feature = feature
  @snapshot = snapshot
  @filters = filters.to_h.symbolize_keys
  @top_orgs = Array(top_orgs)
  @top_users = Array(top_users)
  @request_paths = Array(request_paths)
  @job_usage = Array(job_usage)
  @recent_events = Array(recent_events)
  @recent_events_total_count = recent_events_total_count.to_i
  @usage_series = usage_series.to_h
  @root = Pathname.new(root.to_s)
end

Instance Method Details

#call ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/code_sunset/removal_prompt_builder.rb', line 39

def call
  search_matches = build_search_matches
  warnings = build_warnings(search_matches)
  signals = build_signals(search_matches)

  RemovalPromptArtifact.new(
    prompt_markdown: build_prompt(signals, warnings, search_matches),
    evidence_markdown: build_evidence(signals, warnings, search_matches),
    summary: build_summary,
    search_matches: search_matches,
    signals: signals,
    warnings: warnings
  )
end