# Ruby Calculator - Interactive calculator built with Ruby on Rails
# Author: RSK World (Molla Samser, Founder | Rima Khatun, Designer & Tester)
# Contact: help@rskworld.in | +91 93305 39277
# Website: https://rskworld.in
# Year: 2026
# Description: Build a fully functional calculator using Ruby on Rails with modern UI

class CalculationHistory < ApplicationRecord
  validates :expression, presence: true
  validates :result, presence: true
  validates :operation, presence: true
  
  scope :recent, -> { order(created_at: :desc) }
  scope :by_operation, ->(operation) { where(operation: operation) }
  
  def self.operation_stats
    group(:operation).count
  end
  
  def self.total_calculations
    count
  end
end
