Class: AwanLLM::Tracker

Inherits:
Object
  • Object
show all
Defined in:
lib/walkthrough_awanllm/railtie.rb

Instance Method Summary collapse

Constructor Details

#initialize(app = nil) ⇒ Tracker

Returns a new instance of Tracker.



38
39
40
# File 'lib/walkthrough_awanllm/railtie.rb', line 38

def initialize(app = nil)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



42
43
44
45
# File 'lib/walkthrough_awanllm/railtie.rb', line 42

def call(env)
  status, headers, response = @app.call(env)
  [status, headers, response]
end

#update_activity_logObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/walkthrough_awanllm/railtie.rb', line 47

def update_activity_log
  log_file_path = Rails.root.join('log', 'awanllm_activity.log')
  FileUtils.mkdir_p(File.dirname(log_file_path))

  # Get the latest commit details
  commit_details = `git log -1 --pretty=format:"%H %an %ad %s" --date=iso`
  file_changes = `git diff-tree --no-commit-id --name-status -r HEAD`

  File.open(log_file_path, "a") do |file|
    file.puts("### [#{Time.now}] Activity Log")
    file.puts("#### Commit Details: #{commit_details.strip}")
    file.puts("#### File Changes:")
    file_changes.each_line do |line|
      file.puts("- #{line.strip}")
    end
    file.puts("\n")
  end
end