- Remove no_results status enum value, treat zero results as successful searches - Add processing status for initial log creation - Create TelegramBotLogsHelper#status_color_class to eliminate view duplication - Refactor TelegramBotTask to use Stopwatch class for timing measurements - Add total_request_time column to track end-to-end request duration - Update factories, tests, and views to support new status model - Add comprehensive helper tests and maintain full test coverage
36 lines
605 B
Ruby
36 lines
605 B
Ruby
# typed: strict
|
|
# A simple stopwatch utility for measuring elapsed time
|
|
class Stopwatch
|
|
extend T::Sig
|
|
|
|
sig { params(start_time: Time).void }
|
|
def initialize(start_time)
|
|
@start_time = T.let(start_time, Time)
|
|
end
|
|
|
|
sig { returns(Stopwatch) }
|
|
def self.start
|
|
new(Time.now)
|
|
end
|
|
|
|
sig { returns(Float) }
|
|
def elapsed
|
|
Time.now - @start_time
|
|
end
|
|
|
|
sig { returns(String) }
|
|
def elapsed_ms
|
|
"#{(elapsed * 1000).round(1)}ms"
|
|
end
|
|
|
|
sig { returns(String) }
|
|
def elapsed_s
|
|
"#{sprintf("%.3f", elapsed)}s"
|
|
end
|
|
|
|
sig { returns(Time) }
|
|
def start_time
|
|
@start_time
|
|
end
|
|
end
|