Class: SkillBench::TrendTracker
- Inherits:
-
Object
- Object
- SkillBench::TrendTracker
- Defined in:
- lib/skill_bench/trend_tracker.rb,
lib/skill_bench/trend_tracker/persistence.rb,
lib/skill_bench/trend_tracker/trend_calculator.rb
Overview
Tracks evaluation results over time and computes trend deltas.
Defined Under Namespace
Classes: Persistence, TrendCalculator
Constant Summary collapse
- DEFAULT_HISTORY_FILE =
'.skill-bench-trends.json'
Instance Method Summary collapse
-
#history ⇒ Array<Hash>
Loads the full history.
-
#initialize(history_file: DEFAULT_HISTORY_FILE) ⇒ TrendTracker
constructor
A new instance of TrendTracker.
-
#record(result) ⇒ Hash
Records an evaluation result.
-
#trend_for(result) ⇒ Hash?
Computes the trend of the given result against the most recent matching history entry.
Constructor Details
#initialize(history_file: DEFAULT_HISTORY_FILE) ⇒ TrendTracker
Returns a new instance of TrendTracker.
13 14 15 |
# File 'lib/skill_bench/trend_tracker.rb', line 13 def initialize(history_file: DEFAULT_HISTORY_FILE) @persistence = Persistence.new(history_file) end |
Instance Method Details
#history ⇒ Array<Hash>
Loads the full history.
37 38 39 |
# File 'lib/skill_bench/trend_tracker.rb', line 37 def history @persistence.load end |
#record(result) ⇒ Hash
Records an evaluation result.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/skill_bench/trend_tracker.rb', line 21 def record(result) history = @persistence.load history << extract_entry(result) write_result = @persistence.write(history) return { success: false, response: { error: write_result[:error] } } unless write_result[:success] { success: true, response: { recorded: true } } rescue StandardError => e SkillBench::ErrorLogger.log_error(e, 'TrendTracker Error') { success: false, response: { error: { message: e. } } } end |
#trend_for(result) ⇒ Hash?
Computes the trend of the given result against the most recent matching history entry.
45 46 47 48 49 |
# File 'lib/skill_bench/trend_tracker.rb', line 45 def trend_for(result) entries = @persistence.load current = extract_entry(result) TrendCalculator.compute_trend(entries, current) end |