# frozen_string_literal: true

# == Schema Information
#
# Table name: versions
#
#  id         :bigint           not null, primary key
#  deleted_at :datetime
#  name       :string(191)
#  ord        :integer          default(0)
#  created_at :datetime         not null
#  updated_at :datetime         not null
#  user_id    :bigint
#
class Version < ApplicationRecord
  has_many :article_versions
  has_many :articles, through: :article_versions, source: "article"
  belongs_to :user, optional: true

  def self.list_names(limit)
    Version.where(deleted_at: nil).order(ord: :desc).limit(limit).map(&:name).join(",")
  end
end
