You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: user_checkout_stat.rb
    path of file: ./repos/enju_leaf/app/models
    
    the code of the file until where you have to start completion: class UserCheckoutStat < ApplicationRecord
  include Statesman::Adapters::ActiveRecordQueries[
    transition_class: UserCheckoutStatTransition,
    initial_state: UserCheckoutStatStateMachine.initial_st
    
  def calculate_count!
    self.started_at = Time.zone.now
    User.find_each do |user|
      daily_count = user.checkouts.completed(start_date.beginning_of_day, end_date.tomorrow.beginning_of_day).size
      if daily_count.positive?
        users << user
        sql = ['UPDATE checkout_stat_has_users SET checkouts_count = ? WHERE user_checkout_stat_id = ? AND user_id = ?', daily_count, id, user.id]
        UserCheckoutStat.connection.execute(
          self.class.send(:sanitize_sql_array, sql)
        )
      end
    end