repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/import_request_transition.rb | app/models/import_request_transition.rb | class ImportRequestTransition < ApplicationRecord
belongs_to :import_request, inverse_of: :import_request_transitions
end
# == Schema Information
#
# Table name: import_request_transitions
#
# id :bigint not null, primary key
# metadata :jsonb not null
# most_recent :boolean not null
# sort_key :integer
# to_state :string
# created_at :datetime not null
# updated_at :datetime not null
# import_request_id :bigint
#
# Indexes
#
# index_import_request_transitions_on_import_request_id (import_request_id)
# index_import_request_transitions_on_sort_key_and_request_id (sort_key,import_request_id) UNIQUE
# index_import_request_transitions_parent_most_recent (import_request_id,most_recent) UNIQUE WHERE most_recent
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/order_list_state_machine.rb | app/models/order_list_state_machine.rb | class OrderListStateMachine
include Statesman::Machine
state :pending, initial: true
state :not_ordered
state :ordered
transition from: :pending, to: :not_ordered
transition from: :pending, to: :ordered
transition from: :not_ordered, to: :ordered
before_transition(to: :ordered) do |order_list|
order_list.order
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/user_checkout_stat.rb | app/models/user_checkout_stat.rb | class UserCheckoutStat < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries[
transition_class: UserCheckoutStatTransition,
initial_state: UserCheckoutStatStateMachine.initial_state
]
include CalculateStat
default_scope { order("user_checkout_stats.id DESC") }
scope :not_calculated, -> { in_state(:pending) }
has_many :checkout_stat_has_users, dependent: :destroy
has_many :users, through: :checkout_stat_has_users
belongs_to :user
paginates_per 10
attr_accessor :mode
has_many :user_checkout_stat_transitions, autosave: false, dependent: :destroy
def state_machine
UserCheckoutStatStateMachine.new(self, transition_class: UserCheckoutStatTransition)
end
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
to: :state_machine
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
self.completed_at = Time.zone.now
transition_to!(:completed)
mailer = UserCheckoutStatMailer.completed(self)
mailer.deliver_later
send_message(mailer)
end
end
# == Schema Information
#
# Table name: user_checkout_stats
#
# id :bigint not null, primary key
# completed_at :datetime
# end_date :datetime
# note :text
# start_date :datetime
# started_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_user_checkout_stats_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/bookstore.rb | app/models/bookstore.rb | class Bookstore < ApplicationRecord
default_scope { order("bookstores.position") }
has_many :items, dependent: :restrict_with_exception
acts_as_list
validates :name, presence: true
validates :url, url: true, allow_blank: true, length: { maximum: 255 }
paginates_per 10
if defined?(EnjuPurchaseRequest)
has_many :order_lists, dependent: :restrict_with_exception
end
end
# == Schema Information
#
# Table name: bookstores
#
# id :bigint not null, primary key
# name :text not null
# zip_code :string
# address :text
# note :text
# telephone_number :string
# fax_number :string
# url :string
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/agent_relationship.rb | app/models/agent_relationship.rb | class AgentRelationship < ApplicationRecord
belongs_to :parent, class_name: "Agent"
belongs_to :child, class_name: "Agent"
belongs_to :agent_relationship_type, optional: true
validate :check_parent
acts_as_list scope: :parent_id
def check_parent
errors.add(:parent) if parent_id == child_id
end
end
# == Schema Information
#
# Table name: agent_relationships
#
# id :bigint not null, primary key
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
# agent_relationship_type_id :bigint
# child_id :bigint
# parent_id :bigint
#
# Indexes
#
# index_agent_relationships_on_child_id (child_id)
# index_agent_relationships_on_parent_id (parent_id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/manifestation_checkout_stat_state_machine.rb | app/models/manifestation_checkout_stat_state_machine.rb | class ManifestationCheckoutStatStateMachine
include Statesman::Machine
state :pending, initial: true
state :started
state :completed
transition from: :pending, to: :started
transition from: :started, to: :completed
after_transition(to: :started) do |manifestation_checkout_stat|
manifestation_checkout_stat.update_column(:started_at, Time.zone.now)
manifestation_checkout_stat.calculate_count!
end
after_transition(to: :completed) do |manifestation_checkout_stat|
manifestation_checkout_stat.update_column(:completed_at, Time.zone.now)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/reserve.rb | app/models/reserve.rb | class Reserve < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries[
transition_class: ReserveTransition,
initial_state: ReserveStateMachine.initial_state
]
scope :hold, -> { where.not(item_id: nil) }
scope :not_hold, -> { where(item_id: nil) }
scope :waiting, -> { not_in_state(:completed, :canceled, :expired).where("canceled_at IS NULL AND (expired_at > ? OR expired_at IS NULL)", Time.zone.now) }
scope :retained, -> { in_state(:retained).where.not(retained_at: nil) }
scope :completed, -> { in_state(:completed).where.not(checked_out_at: nil) }
scope :canceled, -> { in_state(:canceled).where.not(canceled_at: nil) }
scope :postponed, -> { in_state(:postponed).where.not(postponed_at: nil) }
scope :will_expire_retained, lambda { |datetime| in_state(:retained).where("checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ?", datetime).order("expired_at") }
scope :will_expire_pending, lambda { |datetime| in_state(:pending).where("checked_out_at IS NULL AND canceled_at IS NULL AND expired_at <= ?", datetime).order("expired_at") }
scope :created, lambda { |start_date, end_date| where("created_at >= ? AND created_at < ?", start_date, end_date) }
scope :not_sent_expiration_notice_to_patron, -> { in_state(:expired).where(expiration_notice_to_patron: false) }
scope :not_sent_expiration_notice_to_library, -> { in_state(:expired).where(expiration_notice_to_library: false) }
scope :sent_expiration_notice_to_patron, -> { in_state(:expired).where(expiration_notice_to_patron: true) }
scope :sent_expiration_notice_to_library, -> { in_state(:expired).where(expiration_notice_to_library: true) }
scope :not_sent_cancel_notice_to_patron, -> { in_state(:canceled).where(expiration_notice_to_patron: false) }
scope :not_sent_cancel_notice_to_library, -> { in_state(:canceled).where(expiration_notice_to_library: false) }
belongs_to :user
belongs_to :manifestation, touch: true
belongs_to :librarian, class_name: "User", optional: true
belongs_to :item, touch: true, optional: true
belongs_to :request_status_type
belongs_to :pickup_location, class_name: "Library", optional: true
validates :expired_at, date: true, allow_blank: true
validate :manifestation_must_include_item
validate :available_for_reservation?, on: :create
validates :item_id, presence: true, if: proc { |reserve|
if item_id_changed?
if reserve.completed? || reserve.retained?
if item_id_change[0]
if item_id_change[1]
true
else
false
end
else
false
end
end
elsif reserve.retained?
true
end
}
validate :valid_item?
validate :retained_by_other_user?
validate :check_expired_at
before_validation :set_manifestation, on: :create
before_validation :set_item
before_validation :set_user, on: :update
before_validation :set_request_status, on: :create
after_create do
transition_to!(:requested)
end
after_save do
if item
item.checkouts.map { |checkout| checkout.index }
Sunspot.commit
end
end
attr_accessor :user_number, :item_identifier, :force_retaining
paginates_per 10
def state_machine
ReserveStateMachine.new(self, transition_class: ReserveTransition)
end
has_many :reserve_transitions, autosave: false, dependent: :destroy
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
to: :state_machine
searchable do
text :username do
user.try(:username)
end
string :username do
user.try(:username)
end
string :user_number do
user.profile.try(:user_number)
end
time :created_at
text :item_identifier do
manifestation.items.pluck(:item_identifier) if manifestation
end
text :title do
manifestation.try(:titles)
end
boolean :hold do |reserve|
hold.include?(reserve)
end
string :state do
current_state
end
string :title_transcription do
manifestation.try(:title_transcription)
end
integer :manifestation_id
end
def set_manifestation
self.manifestation = item.manifestation if item
end
def set_item
identifier = item_identifier.to_s.strip
if identifier.present?
item = Item.find_by(item_identifier: identifier)
self.item = item
end
end
def set_user
number = user_number.to_s.strip
if number.present?
self.user = Profile.find_by(user_number: number).try(:user)
end
end
def valid_item?
if item_identifier.present?
item = Item.find_by(item_identifier: item_identifier)
errors.add(:base, I18n.t("reserve.invalid_item")) unless item
end
end
def retained_by_other_user?
return nil if force_retaining == "1"
if item && !retained?
if Reserve.retained.where(item_id: item.id).count.positive?
errors.add(:base, I18n.t("reserve.attempt_to_update_retained_reservation"))
end
end
end
def set_request_status
self.request_status_type = RequestStatusType.find_by(name: "In Process")
end
def check_expired_at
if canceled_at.blank? && expired_at?
unless completed?
if expired_at.beginning_of_day < Time.zone.now
errors.add(:base, I18n.t("reserve.invalid_date"))
end
end
end
end
def next_reservation
Reserve.waiting.where.not(id: id).order(:created_at).find_by(manifestation_id: manifestation_id)
end
def send_message(sender = nil)
sender ||= User.find(1) # TODO: システムからのメッセージの発信者
Reserve.transaction do
mailer = nil
case current_state
when "requested"
mailer = ReserveMailer.accepted(self)
when "canceled"
mailer = ReserveMailer.canceled(self)
when "expired"
mailer = ReserveMailer.expired(self)
when "retained"
mailer = ReserveMailer.retained(self)
when "postponed"
mailer = ReserveMailer.postponed(self)
else
raise "status not defined"
end
if mailer
mailer.deliver_later
Message.create!(
subject: mailer.subject,
sender: sender,
recipient: user.username,
body: mailer.body.to_s
)
Message.create!(
subject: mailer.subject,
sender: sender,
recipient: sender.username,
body: mailer.body.to_s
)
end
end
end
def self.expire
Reserve.transaction do
will_expire_retained(Time.zone.now.beginning_of_day).readonly(false).map { |r|
r.transition_to!(:expired)
r.send_message
}
will_expire_pending(Time.zone.now.beginning_of_day).readonly(false).map { |r|
r.transition_to!(:expired)
r.send_message
}
end
end
def checked_out_now?
if user && manifestation
true unless (user.checkouts.not_returned.pluck(:item_id) & manifestation.items.pluck("items.id")).empty?
end
end
def available_for_reservation?
if manifestation
if checked_out_now?
errors.add(:base, I18n.t("reserve.this_manifestation_is_already_checked_out"))
end
if manifestation.is_reserved_by?(user)
errors.add(:base, I18n.t("reserve.this_manifestation_is_already_reserved"))
end
if user.try(:reached_reservation_limit?, manifestation)
errors.add(:base, I18n.t("reserve.excessed_reservation_limit"))
end
expired_period = manifestation.try(:reservation_expired_period, user)
if expired_period.nil?
errors.add(:base, I18n.t("reserve.this_patron_cannot_reserve"))
end
end
end
def completed?
[ "canceled", "expired", "completed" ].include?(current_state)
end
def retained?
return true if current_state == "retained"
false
end
private
def do_request
assign_attributes(request_status_type: RequestStatusType.find_by(name: "In Process"), item_id: nil, retained_at: nil)
save!
end
def retain
# TODO: 「取り置き中」の状態を正しく表す
assign_attributes(request_status_type: RequestStatusType.find_by(name: "In Process"), retained_at: Time.zone.now)
Reserve.transaction do
item.next_reservation.try(:transition_to!, :postponed)
save!
end
end
def expire
Reserve.transaction do
assign_attributes(request_status_type: RequestStatusType.find_by(name: "Expired"), canceled_at: Time.zone.now)
reserve = next_reservation
if reserve
reserve.item = item
self.item = nil
save!
reserve.transition_to!(:retained)
end
end
logger.info "#{Time.zone.now} reserve_id #{id} expired!"
end
def cancel
Reserve.transaction do
assign_attributes(request_status_type: RequestStatusType.find_by(name: "Cannot Fulfill Request"), canceled_at: Time.zone.now)
save!
reserve = next_reservation
if reserve
reserve.item = item
self.item = nil
save!
reserve.transition_to!(:retained)
end
end
end
def checkout
assign_attributes(request_status_type: RequestStatusType.find_by(name: "Available For Pickup"), checked_out_at: Time.zone.now)
save!
end
def postpone
assign_attributes(
request_status_type: RequestStatusType.find_by(name: "In Process"),
item_id: nil,
retained_at: nil,
postponed_at: Time.zone.now
)
save!
end
def manifestation_must_include_item
if manifestation && item && !completed?
errors.add(:base, I18n.t("reserve.invalid_item")) unless manifestation.items.include?(item)
end
end
if defined?(EnjuInterLibraryLoan)
has_one :inter_library_loan
end
end
# == Schema Information
#
# Table name: reserves
#
# id :bigint not null, primary key
# canceled_at :datetime
# checked_out_at :datetime
# expiration_notice_to_library :boolean default(FALSE)
# expiration_notice_to_patron :boolean default(FALSE)
# expired_at :datetime
# lock_version :integer default(0), not null
# postponed_at :datetime
# retained_at :datetime
# created_at :datetime not null
# updated_at :datetime not null
# item_id :bigint
# manifestation_id :bigint not null
# pickup_location_id :bigint
# request_status_type_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_reserves_on_item_id (item_id)
# index_reserves_on_manifestation_id (manifestation_id)
# index_reserves_on_pickup_location_id (pickup_location_id)
# index_reserves_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (manifestation_id => manifestations.id)
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/order_list.rb | app/models/order_list.rb | class OrderList < ApplicationRecord
include Statesman::Adapters::ActiveRecordQueries[
transition_class: OrderListTransition,
initial_state: :pending
]
scope :not_ordered, -> { in_state(:not_ordered) }
has_many :orders, dependent: :destroy
has_many :purchase_requests, through: :orders
belongs_to :user, validate: true
belongs_to :bookstore, validate: true
has_many :subscriptions
after_create do
transition_to(:not_ordered)
end
validates_presence_of :title, :user, :bookstore
validates_associated :user, :bookstore
attr_accessor :edit_mode
paginates_per 10
def state_machine
OrderListStateMachine.new(self, transition_class: OrderListTransition)
end
has_many :order_list_transitions, autosave: false
delegate :can_transition_to?, :transition_to!, :transition_to, :current_state,
to: :state_machine
def total_price
purchase_requests.sum(:price)
end
def order
self.ordered_at = Time.zone.now
end
def ordered?
true if current_state == "ordered"
end
end
# == Schema Information
#
# Table name: order_lists
#
# id :bigint not null, primary key
# note :text
# ordered_at :datetime
# title :text not null
# created_at :datetime not null
# updated_at :datetime not null
# bookstore_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_order_lists_on_bookstore_id (bookstore_id)
# index_order_lists_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (bookstore_id => bookstores.id)
# fk_rails_... (user_id => users.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/event_category.rb | app/models/event_category.rb | class EventCategory < ApplicationRecord
# include MasterModel
validates :name, presence: true
acts_as_list
default_scope { order("position") }
has_many :events, dependent: :restrict_with_exception
paginates_per 10
end
# == Schema Information
#
# Table name: event_categories
#
# id :bigint not null, primary key
# name :string not null
# display_name :text
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/agent_type.rb | app/models/agent_type.rb | class AgentType < ApplicationRecord
include MasterModel
has_many :agents, dependent: :restrict_with_exception
end
# == Schema Information
#
# Table name: agent_types
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_agent_types_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/produce_type.rb | app/models/produce_type.rb | class ProduceType < ApplicationRecord
include MasterModel
default_scope { order("produce_types.position") }
end
# == Schema Information
#
# Table name: produce_types
#
# id :bigint not null, primary key
# display_name :text
# name :string not null
# note :text
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_produce_types_on_lower_name (lower((name)::text)) UNIQUE
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/user.rb | app/models/user.rb | class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :lockable
include EnjuSeed::EnjuUser
include EnjuCirculation::EnjuUser
include EnjuMessage::EnjuUser
include EnjuBookmark::EnjuUser
include EnjuPurchaseRequest::EnjuUser
validates :profile, uniqueness: true
end
# == Schema Information
#
# Table name: users
#
# id :bigint not null, primary key
# confirmed_at :datetime
# email :string default(""), not null
# encrypted_password :string default(""), not null
# expired_at :datetime
# failed_attempts :integer default(0)
# locked_at :datetime
# remember_created_at :datetime
# reset_password_sent_at :datetime
# reset_password_token :string
# unlock_token :string
# username :string
# created_at :datetime not null
# updated_at :datetime not null
# profile_id :bigint not null
#
# Indexes
#
# index_users_on_email (email)
# index_users_on_profile_id (profile_id)
# index_users_on_reset_password_token (reset_password_token) UNIQUE
# index_users_on_unlock_token (unlock_token) UNIQUE
# index_users_on_username (username) UNIQUE
#
# Foreign Keys
#
# fk_rails_... (profile_id => profiles.id)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/localized_name.rb | app/models/concerns/localized_name.rb | module LocalizedName
def localize(locale = I18n.locale)
string = YAML.load(self)
if string.is_a?(Hash) && string[locale.to_s]
return string[locale.to_s]
end
self
rescue NoMethodError
self
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_nii.rb | app/models/concerns/enju_nii.rb | module EnjuNii
class AlreadyImported < StandardError
end
class RecordNotFound < StandardError
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/export_file.rb | app/models/concerns/export_file.rb | module ExportFile
extend ActiveSupport::Concern
included do
belongs_to :user
attr_accessor :mode
end
def send_message(mailer)
sender = User.find(1)
message = Message.create!(
recipient: user.username,
sender: sender,
body: mailer.body.raw_source,
subject: mailer.subject
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/bookmark_url.rb | app/models/concerns/bookmark_url.rb | module BookmarkUrl
def my_host?
url = ::Addressable::URI.parse(self)
unless url.host
raise ::Addressable::URI::InvalidURIError
end
config_url = ::Addressable::URI.parse(LibraryGroup.site_config.url)
if url.host == config_url.host and url.port == config_url.port and [ "http", "https" ].include?(url.scheme)
true
else
false
end
end
def bookmarkable?
if self.my_host?
url = ::Addressable::URI.parse(self)
path = url.path.split("/").reverse
if path[1] == "manifestations" and Manifestation.where(id: path[0]).first
true
else
false
end
else
true
end
rescue ::Addressable::URI::InvalidURIError
false
end
def bookmarkable_id
if self.my_host?
path = ::Addressable::URI.parse(self).path.split("/").reverse
unless path[1] == "manifestations"
nil
else
path[0]
end
end
end
end
class String
include BookmarkUrl
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/calculate_stat.rb | app/models/concerns/calculate_stat.rb | module CalculateStat
extend ActiveSupport::Concern
included do
validates :start_date, :end_date, presence: true
validate :check_date
# 利用統計の集計を開始します。
def self.calculate_stat
self.not_calculated.each do |stat|
stat.transition_to!(:started)
end
end
end
# 利用統計の日付をチェックします。
def check_date
if self.start_date && self.end_date
if self.start_date >= self.end_date
errors.add(:start_date)
errors.add(:end_date)
end
end
end
# 利用統計の集計完了メッセージを送信します。
def send_message(mailer)
sender = User.find(1) # system
message = Message.create!(
recipient: user.username,
sender: sender,
body: mailer.body.raw_source,
subject: mailer.subject
)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/master_model.rb | app/models/concerns/master_model.rb | module MasterModel
extend ActiveSupport::Concern
included do
acts_as_list
validates :name, uniqueness: { case_sensitive: false }
validates :name, presence: true
validate :name do
valid_name?
end
validate :display_name do
valid_yaml?
end
validates :display_name, presence: true
before_validation :set_display_name, on: :create
strip_attributes only: :name
end
# 表示名を設定します。
def set_display_name
self.display_name = "#{I18n.locale}: #{name}" if display_name.blank?
end
private
def valid_name?
unless name =~ /\A[a-z][0-9a-z_]*[0-9a-z]\z/
errors.add(:name, I18n.t("page.only_lowercase_letters_and_numbers_are_allowed"))
end
end
def valid_yaml?
begin
YAML.load(display_name)
rescue Psych::SyntaxError
errors.add(:display_name, I18n.t("page.cannot_parse_yaml_header"))
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_loc.rb | app/models/concerns/enju_loc.rb | module EnjuLoc
class AlreadyImported < StandardError
end
class RecordNotFound < StandardError
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/import_file.rb | app/models/concerns/import_file.rb | module ImportFile
extend ActiveSupport::Concern
# 失敗したインポート処理を一括削除します。
def self.expire
self.stucked.find_each do |file|
file.destroy
end
end
def import_start
case edit_mode
when "create"
import
when "update"
modify
when "destroy"
remove
else
import
end
end
# インポートするファイルの文字コードをUTF-8に変換します。
# @param [String] line 変換する文字列
def convert_encoding(line)
if defined?(CharlockHolmes::EncodingDetector)
begin
case user_encoding
when "auto_detect"
encoding = CharlockHolmes::EncodingDetector.detect(line)[:encoding]
when nil
encoding = CharlockHolmes::EncodingDetector.detect(line)[:encoding]
else
encoding = user_encoding
end
line.encode("UTF-8", encoding, universal_newline: true)
rescue StandardError
nkf_encode(line)
end
else
nkf_encode(line)
end
end
# インポート完了時のメッセージを送信します。
def send_message(mailer)
sender = User.find(1)
message = Message.create!(
recipient: user.username,
sender: sender,
body: mailer.body.raw_source,
subject: mailer.subject
)
end
private
def nkf_encode(line)
case user_encoding
when "auto_detect"
output_encoding = "-w"
when "UTF-8"
output_encoding = ""
when "Shift_JIS"
output_encoding = "-Sw"
when "EUC-JP"
output_encoding = "-Ew"
else
output_encoding = "-w"
end
NKF.nkf("#{output_encoding} -Lu", line)
end
def create_import_temp_file(attachment)
tempfile = Tempfile.new(self.class.name.underscore)
tempfile.write convert_encoding(attachment.download)
tempfile.close
tempfile
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_ndl.rb | app/models/concerns/enju_ndl.rb | module EnjuNdl
class AlreadyImported < StandardError
end
class RecordNotFound < StandardError
end
class InvalidIsbn < StandardError
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_oai/dcndl.rb | app/models/concerns/enju_oai/dcndl.rb | module EnjuOai
class Dcndl < OAI::Provider::Metadata::Format
def initialize
@prefix = "dcndl"
@schema = nil
@namespace = "http://ndl.go.jp/dcndl/terms/"
@element_namespace = "dc"
@fields = [ :title, :creator, :subject, :description, :publisher,
:contributor, :date, :type, :format, :identifier,
:source, :language, :relation, :coverage, :rights ]
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_oai/oai_model.rb | app/models/concerns/enju_oai/oai_model.rb | module EnjuOai
module OaiModel
extend ActiveSupport::Concern
OAI::Provider::Base.register_format(EnjuOai::Jpcoar.instance)
OAI::Provider::Base.register_format(EnjuOai::Dcndl.instance)
def to_oai_dc
xml = Builder::XmlMarkup.new
xml.tag!("oai_dc:dc",
"xmlns:oai_dc" => "http://www.openarchives.org/OAI/2.0/oai_dc/",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" =>
%(http://www.openarchives.org/OAI/2.0/oai_dc/
http://www.openarchives.org/OAI/2.0/oai_dc.xsd)) do
xml.tag! "dc:title", original_title
creators.readable_by(nil).each do |creator|
xml.tag! "dc:creator", creator.full_name
end
subjects.each do |subject|
xml.tag! "dc:subject", subject.term
end
xml.tag! "dc:description", description
end
xml.target!
end
def to_jpcoar
xml = Builder::XmlMarkup.new
xml.tag!("jpcoar:jpcoar", "xsi:schemaLocation" => "https://github.com/JPCOAR/schema/blob/master/1.0/jpcoar_scm.xsd",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xmlns:rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xmlns:rioxxterms" => "http://www.rioxx.net/schema/v2.0/rioxxterms/",
"xmlns:datacite" => "https://schema.datacite.org/meta/kernel-4/",
"xmlns:oaire" => "http://namespace.openaire.eu/schema/oaire/",
"xmlns:dcndl" => "http://ndl.go.jp/dcndl/terms/",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:jpcoar" => "https://github.com/JPCOAR/schema/blob/master/1.0/") do
xml.tag! "dc:title", original_title
xml.tag! "dc:language", language.iso_639_2
xml.tag! "jpcoar:creators" do
creators.readable_by(nil).each do |creator|
xml.tag! "jpcoar:creatorName", creator.full_name
end
end
subjects.each do |subject|
xml.tag! "jpcoar:subject", subject.term
end
if attachment.attached?
xml.tag! "jpcoar:file" do
xml.tag! "jpcoar:URI", Rails.application.routes.url_helpers.rails_storage_proxy_url(fileset.attachment, host: ENV["ENJU_LEAF_BASE_URL"])
end
end
end
xml.target!
end
def to_dcndl
xml = Builder::XmlMarkup.new
xml.tag! "rdf:RDF",
"xmlns:rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xmlns:dcterms" => "http://purl.org/dc/terms/",
"xmlns:dcndl" => "http://ndl.go.jp/dcndl/terms/",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:rdfs" => "http://www.w3.org/2000/01/rdf-schema#",
"xmlns:owl" => "http://www.w3.org/2002/07/owl#",
"xmlns:foaf" => "http://xmlns.com/foaf/0.1/" do
get_record_url = URI.join(ENV["ENJU_LEAF_BASE_URL"], "/oai?verb=GetRecord&metadataPrefix=dcndl&identifier=#{oai_identifier}")
xml.tag! "dcndl:BibAdminResource", "rdf:about" => get_record_url do
xml.tag! "dcndl:record", "rdf:resource" => get_record_url + "#material"
xml.tag! "dcndl:bibRecordCategory", ENV["DCNDL_BIBRECORDCATEGORY"]
end
xml.tag! "dcndl:BibResource", "rdf:about" => get_record_url + "#material" do
xml.tag! "rdfs:seeAlso", "rdf:resource" => URI.join(ENV["ENJU_LEAF_BASE_URL"], "/manifestations/#{id}")
identifiers.each do |identifier|
case identifier.identifier_type.try(:name)
when "isbn"
# xml.tag! "rdfs:seeAlso", "rdf:resource" => "http://iss.ndl.go.jp/isbn/#{identifier.body}"
xml.tag! "dcterms:identifier", identifier.body, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/ISBN"
when "issn"
xml.tag! "dcterms:identifier", identifier.body, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/ISSN"
when "doi"
xml.tag! "dcterms:identifier", identifier.body, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/DOI"
when "ncid"
xml.tag! "dcterms:identifier", identifier.body, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/NIIBibID"
end
xml.tag! "dcterms:identifier", doi_record.body, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/DOI" if doi_record
end
xml.tag! "dcterms:title", original_title
xml.tag! "dc:title" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", original_title
if title_transcription?
xml.tag! "dcndl:transcription", title_transcription
end
end
end
if title_alternative?
xml.tag! "dcndl:alternative" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", title_alternative
if title_alternative_transcription?
xml.tag! "dcndl:transcription", title_alternative_transcription
end
end
end
end
if volume_number_string?
xml.tag! "dcndl:volume" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", volume_number_string
end
end
elsif volume_number?
xml.tag! "dcndl:volume" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", volume_number
end
end
end
series_statements.each do |series_statement|
xml.tag! "dcndl:seriesTitle" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", series_statement.original_title
if series_statement.title_transcription?
xml.tag! "dcndl:transcription", series_statement.title_transcription
end
end
end
end
if edition_string?
xml.tag! "dcndl:edition", edition_string
elsif edition?
xml.tag! "dcndl:edition", edition
end
unless creators.readable_by(nil).empty?
creators.readable_by(nil).each do |creator|
xml.tag! "dcterms:creator" do
xml.tag! "foaf:Agent" do
xml.tag! "foaf:name", creator.full_name
if creator.full_name_transcription?
xml.tag! "dcndl:transcription", creator.full_name_transcription
end
end
end
end
end
xml.tag! "dc:creator", statement_of_responsibility if statement_of_responsibility.present?
series_statements.each do |series_statement|
xml.tag! "dcndl:seriesCreator", series_statement.creator_string
end
contributors.readable_by(nil).each do |contributor|
xml.tag! "dcndl:contributor", contributor.full_name
end
publishers.readable_by(nil).each do |publisher|
xml.tag! "dcterms:publisher" do
xml.tag! "foaf:Agent" do
if publisher.corporate_name
xml.tag! "foaf:name", publisher.corporate_name
xml.tag! "dcndl:transcription", publisher.corporate_name_transcription if publisher.corporate_name_transcription?
elsif publisher.full_name
xml.tag! "foaf:name", publisher.full_name
xml.tag! "dcndl:transcription", publisher.full_name_transcription if publisher.full_name_transcription?
end
xml.tag! "dcterms:description", publisher.note if publisher.note?
xml.tag! "dcndl:location", publisher.place if publisher.place?
end
end
end
publishers.readable_by(nil).each do |publisher|
xml.tag! "dcndl:publicationPlace", publisher.country.alpha_2 if publisher.country.try(:name) != "unknown"
end
xml.tag! "dcterms:issued", pub_date, "rdf:datatype" => "http://purl.org/dc/terms/W3CDTF" if pub_date?
xml.tag! "dcterms:description", description if description?
subjects.each do |subject|
xml.tag! "dcterms:subject" do
xml.tag! "rdf:Description" do
xml.tag! "rdf:value", subject.term
xml.tag! "dcndl:transcription", subject.term_transcription if subject.term_transcription?
end
end
end
classifications.each do |classification|
case classification.classification_type.name
when "ndlc"
xml.tag! "dcterms:subject", "rdf:resource" => "http://id.ndl.go.jp/class/ndlc/" + classification.category
when "ndc9"
xml.tag! "dcterms:subject", "rdf:resource" => "http://id.ndl.go.jp/class/ndc9/" + classification.category
when "ddc"
xml.tag! "dcterms:subject", "rdf:resource" => "http://dewey.info/class/" + classification.category
when "ndc8"
xml.tag! "dc:subject", classification.category, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/NDC8"
when "ndc"
xml.tag! "dc:subject", classification.category, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/NDC"
when "lcc"
xml.tag! "dc:subject", classification.category, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/LCC"
when "udc"
xml.tag! "dc:subject", classification.category, "rdf:datatype" => "http://ndl.go.jp/dcndl/terms/UDC"
end
end
xml.tag! "dcterms:language", language.iso_639_2, "rdf:datatype" => "http://purl.org/dc/terms/ISO639-2"
xml.tag! "dcndl:price", price if price?
if extent? || dimensions?
xml.tag! "dcterms:extent", [ extent, dimensions ].compact.join(" ; ")
end
material_type = nil
case carrier_type.name
when "volume"
material_type = :book
when "online_resource"
material_type = :electronic_resource
end
case manifestation_content_type&.name
when "text"
material_type = :book
when "tactile_text"
material_type = :braille
when "cartographic_image"
material_type = :map
when "performed_music"
material_type = :music
when "notated_music"
material_type = :music_score
when "still_image"
material_type = :still_image
when "two_dimensional_moving_image"
material_type = :moving_image
when "sounds"
material_type = :sound
end
case material_type
when :book
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/Book", "rdfs:label" => "図書"
when :electronic_resource
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/ElectronicResource", "rdfs:label" => "電子資料"
when :braille
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/Braille", "rdfs:label" => "点字"
when :map
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/Map", "rdfs:label" => "地図"
when :music
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/Music", "rdfs:label" => "音楽"
when :music_score
xml.tag! "dcndl:materialType", "rdf:resource" => "http://ndl.go.jp/ndltype/MusicScore", "rdfs:label" => "楽譜"
when :still_image
xml.tag! "dcndl:materialType", "rdf:resource" => "http://purl.org/dc/dcmitype/StillImage", "rdfs:label" => "静止画資料"
when :moving_image
xml.tag! "dcndl:materialType", "rdf:resource" => "http://purl.org/dc/dcmitype/MovingImage", "rdfs:label" => "映像資料"
when :sound
xml.tag! "dcndl:materialType", "rdf:resource" => "http://purl.org/dc/dcmitype/Sound", "rdfs:label" => "録音資料"
end
if serial && frequency
xml.tag! "dcndl:publicationPeriodicity", frequency.name
end
end
end
xml.target!
end
def self.repository_url
URI.join(ENV["ENJU_LEAF_BASE_URL"], "/oai")
end
def self.record_prefix
"oai:#{URI.parse(ENV['ENJU_LEAF_BASE_URL']).host}:manifestations"
end
def oai_identifier
[ EnjuOai::OaiModel.record_prefix, id ].join(":")
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_oai/jpcoar.rb | app/models/concerns/enju_oai/jpcoar.rb | module EnjuOai
class Jpcoar < OAI::Provider::Metadata::Format
def initialize
@prefix = "jpcoar"
@schema = "https://github.com/JPCOAR/schema/blob/master/1.0/jpcoar_scm.xsd"
@namespace = "https://github.com/JPCOAR/schema/blob/master/1.0/"
@element_namespace = "dc"
@fields = [ :title, :creator, :subject, :description, :publisher,
:contributor, :date, :type, :format, :identifier,
:source, :language, :relation, :coverage, :rights ]
end
def header_specification
{
"xmlns:jpcoar" => "https://github.com/JPCOAR/schema/blob/master/1.0/",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"xsi:schemaLocation" =>
%(https://github.com/JPCOAR/schema/blob/master/1.0/
jpcoar_scm.xsd).gsub(/\s+/, " ")
}
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_purchase_request/enju_user.rb | app/models/concerns/enju_purchase_request/enju_user.rb | module EnjuPurchaseRequest
module EnjuUser
extend ActiveSupport::Concern
included do
has_many :purchase_requests
has_many :order_lists
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_profile.rb | app/models/concerns/enju_circulation/enju_profile.rb | module EnjuCirculation
module EnjuProfile
extend ActiveSupport::Concern
def reset_checkout_icalendar_token
self.checkout_icalendar_token = SecureRandom.hex(16)
end
def delete_checkout_icalendar_token
self.checkout_icalendar_token = nil
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_user.rb | app/models/concerns/enju_circulation/enju_user.rb | module EnjuCirculation
module EnjuUser
extend ActiveSupport::Concern
included do
has_many :checkouts, dependent: :restrict_with_exception
has_many :reserves, dependent: :destroy
has_many :reserved_manifestations, through: :reserves, source: :manifestation, dependent: :destroy
has_many :checkout_stat_has_users, dependent: :destroy
has_many :user_checkout_stats, through: :checkout_stat_has_users
has_many :reserve_stat_has_users, dependent: :destroy
has_many :user_reserve_stats, through: :reserve_stat_has_users
has_many :baskets, dependent: :destroy
before_destroy :check_item_before_destroy
end
def check_item_before_destroy
# TODO: 貸出記録を残す場合
if checkouts.size.positive?
raise "This user has items still checked out."
end
end
def checked_item_count
checkout_count = {}
CheckoutType.find_each do |checkout_type|
# 資料種別ごとの貸出中の冊数を計算
checkout_count[:"#{checkout_type.name}"] = checkouts.count_by_sql([ "
SELECT count(item_id) FROM checkouts
WHERE item_id IN (
SELECT id FROM items
WHERE checkout_type_id = ?
)
AND user_id = ? AND checkin_id IS NULL", checkout_type.id, id ]
)
end
checkout_count
end
def reached_reservation_limit?(manifestation)
return true if profile.user_group.user_group_has_checkout_types.available_for_carrier_type(manifestation.carrier_type).where(user_group_id: profile.user_group.id).collect(&:reservation_limit).max.to_i <= reserves.waiting.size
false
end
def has_overdue?(day = 1)
true if checkouts.where(checkin_id: nil).where(Checkout.arel_table[:due_date].lt day.days.ago).count >= 1
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_withdraw.rb | app/models/concerns/enju_circulation/enju_withdraw.rb | module EnjuCirculation
module EnjuWithdraw
extend ActiveSupport::Concern
included do
before_create :withdraw!
validate :check_item
end
def withdraw!
circulation_status = CirculationStatus.find_by(name: "Removed")
item.update_column(:circulation_status_id, circulation_status.id) if circulation_status
item.use_restriction = UseRestriction.find_by(name: "Not For Loan")
item.index!
end
def check_item
errors.add(:item_id, :is_rented) if item.try(:rent?)
errors.add(:item_id, :is_reserved) if item.try(:reserved?)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_accept.rb | app/models/concerns/enju_circulation/enju_accept.rb | module EnjuCirculation
module EnjuAccept
extend ActiveSupport::Concern
included do
before_create :accept!
after_create do
item.save
end
end
def accept!
item.circulation_status = CirculationStatus.find_by(name: "Available On Shelf")
item.use_restriction = UseRestriction.find_by(name: "Limited Circulation, Normal Loan Period")
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_carrier_type.rb | app/models/concerns/enju_circulation/enju_carrier_type.rb | module EnjuCirculation
module EnjuCarrierType
extend ActiveSupport::Concern
included do
has_many :carrier_type_has_checkout_types, dependent: :destroy
has_many :checkout_types, through: :carrier_type_has_checkout_types
accepts_nested_attributes_for :carrier_type_has_checkout_types, allow_destroy: true, reject_if: :all_blank
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_item.rb | app/models/concerns/enju_circulation/enju_item.rb | module EnjuCirculation
module EnjuItem
extend ActiveSupport::Concern
included do
FOR_CHECKOUT_CIRCULATION_STATUS = [
"Available On Shelf",
"On Loan",
"Waiting To Be Reshelved"
]
FOR_CHECKOUT_USE_RESTRICTION = [
"Available For Supply Without Return",
"Limited Circulation, Long Loan Period",
"Limited Circulation, Short Loan Period",
"No Reproduction",
"Overnight Only",
"Renewals Not Permitted",
"Supervision Required",
"Term Loan",
"User Signature Required",
"Limited Circulation, Normal Loan Period"
]
scope :for_checkout, ->(identifier_conditions = "item_identifier IS NOT NULL") {
includes(:circulation_status, :use_restriction).where(
"circulation_statuses.name" => FOR_CHECKOUT_CIRCULATION_STATUS,
"use_restrictions.name" => FOR_CHECKOUT_USE_RESTRICTION
).where(identifier_conditions)
}
has_many :checkouts, dependent: :restrict_with_exception
has_many :checkins, dependent: :destroy
has_many :reserves, dependent: :nullify
has_many :checked_items, dependent: :destroy
has_many :baskets, through: :checked_items
belongs_to :circulation_status
belongs_to :checkout_type
has_one :item_has_use_restriction, dependent: :destroy
has_one :use_restriction, through: :item_has_use_restriction
validate :check_circulation_status
searchable do
string :circulation_status do
circulation_status.name
end
end
accepts_nested_attributes_for :item_has_use_restriction
end
def set_circulation_status
self.circulation_status = CirculationStatus.find_by(name: "In Process") if circulation_status.nil?
end
def check_circulation_status
return unless circulation_status.name == "Removed"
errors.add(:base, I18n.t("activerecord.errors.models.item.attributes.circulation_status_id.is_rented")) if rented?
errors.add(:base, I18n.t("activerecord.errors.models.item.attributes.circulation_status_id.is_reserved")) if reserved?
end
def checkout_status(user)
return nil unless user
user.profile.user_group.user_group_has_checkout_types.find_by(checkout_type_id: checkout_type.id)
end
def reserved?
return true if manifestation.next_reservation
false
end
def rent?
return true if checkouts.not_returned.select(:item_id).detect { |checkout| checkout.item_id == id }
false
end
def rented?
rent?
end
def user_reservation(user)
user.reserves.waiting.order("reserves.created_at").find_by(manifestation: manifestation)
end
def available_for_checkout?
if circulation_status.name == "On Loan"
false
else
manifestation.items.for_checkout.include?(self)
end
end
def checkout!(user)
Item.transaction do
reserve = user_reservation(user)
if reserve && !reserve.state_machine.in_state?(:completed)
reserve.checked_out_at = Time.zone.now
reserve.state_machine.transition_to!(:completed)
end
update!(circulation_status: CirculationStatus.find_by(name: "On Loan"))
end
end
def checkin!
self.circulation_status = CirculationStatus.find_by(name: "Available On Shelf")
save!
end
def retain(librarian)
self.class.transaction do
reservation = manifestation.next_reservation
if reservation
reservation.item = self
reservation.transition_to!(:retained) unless reservation.retained?
reservation.send_message(librarian)
end
end
end
def retained?
manifestation.reserves.retained.each do |reserve|
if reserve.item == self
return true
end
end
false
end
def not_for_loan?
!manifestation.items.for_checkout.include?(self)
end
def next_reservation
Reserve.waiting.find_by(item_id: id)
end
def latest_checkout
checkouts.not_returned.order(created_at: :desc).first
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_basket.rb | app/models/concerns/enju_circulation/enju_basket.rb | module EnjuCirculation
module EnjuBasket
extend ActiveSupport::Concern
included do
has_many :checked_items, dependent: :destroy
has_many :items, through: :checked_items
has_many :checkouts, dependent: :restrict_with_exception
has_many :checkins, dependent: :restrict_with_exception
end
def basket_checkout(librarian)
return nil if checked_items.size.zero?
Item.transaction do
checked_items.each do |checked_item|
checked_item.item.reload
checkout = user.checkouts.create!(
librarian: librarian,
item: checked_item.item,
basket: self,
library: librarian.profile.library,
shelf: checked_item.item.shelf,
due_date: checked_item.due_date
)
checked_item.item.checkout!(user)
end
CheckedItem.where(basket_id: id).destroy_all
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_user_group.rb | app/models/concerns/enju_circulation/enju_user_group.rb | module EnjuCirculation
module EnjuUserGroup
extend ActiveSupport::Concern
included do
has_many :user_group_has_checkout_types, dependent: :destroy
has_many :checkout_types, through: :user_group_has_checkout_types
accepts_nested_attributes_for :user_group_has_checkout_types, allow_destroy: true, reject_if: :all_blank
validates :number_of_day_to_notify_due_date,
:number_of_day_to_notify_overdue,
:number_of_time_to_notify_overdue,
numericality: { greater_than_or_equal_to: 0 }
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_circulation/enju_manifestation.rb | app/models/concerns/enju_circulation/enju_manifestation.rb | module EnjuCirculation
module EnjuManifestation
extend ActiveSupport::Concern
included do
has_many :reserves, foreign_key: :manifestation_id, inverse_of: :manifestation, dependent: :restrict_with_exception
searchable do
boolean :reservable do
reservable?
end
end
end
def next_reservation
reserves.waiting.not_in_state(:retained).order("reserves.created_at ASC").readonly(false).first
end
def available_checkout_types(user)
if user
user.profile.user_group.user_group_has_checkout_types.available_for_carrier_type(carrier_type)
end
end
def is_reservable_by?(user)
return false if items.for_checkout.empty?
return false unless user
unless user.has_role?("Librarian")
unless items.size == (items.size - user.checkouts.overdue(Time.zone.now).collect(&:item).size)
return false
end
end
true
end
def is_reserved_by?(user)
return nil unless user
reserve = Reserve.waiting.find_by(user_id: user.id, manifestation_id: id)
if reserve
reserve
else
false
end
end
def is_reserved?
if reserves.present?
true
else
false
end
end
def checkouts(start_date, end_date)
Checkout.completed(start_date, end_date).where(item_id: items.collect(&:id))
end
def checkout_period(user)
if available_checkout_types(user)
available_checkout_types(user).collect(&:checkout_period).max || 0
end
end
def reservation_expired_period(user)
if available_checkout_types(user)
available_checkout_types(user).collect(&:reservation_expired_period).max || 0
end
end
def is_checked_out_by?(user)
if items.size > items.size - user.checkouts.not_returned.collect(&:item).size
true
else
false
end
end
def reservable?
items.for_checkout.exists?
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_seed/enju_user.rb | app/models/concerns/enju_seed/enju_user.rb | module EnjuSeed
module EnjuUser
extend ActiveSupport::Concern
included do
scope :administrators, -> { joins(:role).where("roles.name = ?", "Administrator") }
scope :librarians, -> { joins(:role).where("roles.name = ? OR roles.name = ?", "Administrator", "Librarian") }
scope :suspended, -> { where.not(locked_at: nil) }
belongs_to :profile
if defined?(EnjuBiblio)
has_many :import_requests, dependent: :restrict_with_exception
has_many :picture_files, as: :picture_attachable, dependent: :destroy
end
has_one :user_has_role, dependent: :destroy
has_one :role, through: :user_has_role
accepts_nested_attributes_for :user_has_role
validates :username, presence: true, uniqueness: true, format: {
with: /\A[0-9A-Za-z][0-9A-Za-z_\-]*[0-9A-Za-z]\z/
}
validates :email, format: Devise::email_regexp, allow_blank: true, uniqueness: true
validates :expired_at, date: true, allow_blank: true
with_options if: :password_required? do |v|
v.validates_presence_of :password
v.validates_confirmation_of :password
v.validates_length_of :password, allow_blank: true,
within: Devise::password_length
end
before_destroy :check_role_before_destroy
before_save :check_expiration
after_create :set_confirmation
after_save :set_lock_information
extend FriendlyId
friendly_id :username
strip_attributes only: :username
strip_attributes only: :email, allow_empty: true
attr_accessor :password_not_verified,
:update_own_account, :auto_generated_password,
:locked, :current_password # , :agent_id
paginates_per 10
def send_devise_notification(notification, *args)
devise_mailer.send(notification, self, *args).deliver_later
end
# 有効期限切れのユーザを一括で使用不可にします。
def self.lock_expired_users
User.find_each do |user|
user.lock_access! if user.expired? && user.active_for_authentication?
end
end
# ユーザの情報をエクスポートします。
# @param [Hash] options
def self.export(options = { format: :text })
header = %w[
username
full_name
full_name_transcription
email
user_number
role
user_group
library
locale
locked
required_role
created_at
updated_at
expired_at
keyword_list
note
]
header += %w[
checkout_icalendar_token
save_checkout_history
] if defined? EnjuCirculation
header << "save_search_history" if defined? EnjuSearchLog
header << "share_bookmarks" if defined? EnjuBookmark
lines = []
User.find_each.map { |u|
line = []
line << u.username
line << u.try(:profile).try(:full_name)
line << u.try(:profile).try(:full_name_transcription)
line << u.email
line << u.try(:profile).try(:user_number)
line << u.role.try(:name)
line << u.try(:profile).try(:user_group).try(:name)
line << u.try(:profile).try(:library).try(:name)
line << u.try(:profile).try(:locale)
line << u.access_locked?
line << u.try(:profile).try(:required_role).try(:name)
line << u.created_at
line << u.updated_at
line << u.try(:profile).try(:expired_at)
line << u.try(:profile).try(:keyword_list).try(:split).try(:join, "//")
line << u.try(:profile).try(:note)
if defined? EnjuCirculation
line << u.try(:profile).try(:checkout_icalendar_token)
line << u.try(:profile).try(:save_checkout_history)
end
if defined? EnjuSearchLog
line << u.try(:profile).try(:save_search_history)
end
if defined? EnjuBookmark
line << u.try(:profile).try(:share_bookmarks)
end
lines << line
}
if options[:format] == :text
lines.map { |line| line.to_csv(col_sep: "\t") }.unshift(header.to_csv(col_sep: "\t")).join
else
lines
end
end
end
# ユーザにパスワードが必要かどうかをチェックします。
# @return [Boolean]
def password_required?
if Devise.mappings[:user].modules.include?(:database_authenticatable)
!persisted? || !password.nil? || !password_confirmation.nil?
end
end
# ユーザが特定の権限を持っているかどうかをチェックします。
# @param [String] role_in_question 権限名
# @return [Boolean]
def has_role?(role_in_question)
return false unless role
return true if role.name == role_in_question
case role.name
when "Administrator"
true
when "Librarian"
true if role_in_question == "User"
else
false
end
end
# ユーザに使用不可の設定を反映させます。
def set_lock_information
if locked == "1" && active_for_authentication?
lock_access!
elsif locked == "0" && !active_for_authentication?
unlock_access!
end
end
def set_confirmation
if respond_to?(:confirm!)
reload
confirm!
end
end
# ユーザが有効期限切れかどうかをチェックし、期限切れであれば使用不可に設定します。
# @return [Object]
def check_expiration
return if has_role?("Administrator")
if expired_at
if expired_at.beginning_of_day < Time.zone.now.beginning_of_day
lock_access! if active_for_authentication?
end
end
end
# ユーザの削除前に、管理者ユーザが不在にならないかどうかをチェックします。
# @return [Object]
def check_role_before_destroy
if has_role?("Administrator")
if Role.find_by(name: "Administrator").users.count == 0
raise "#{username} is the last administrator in this system."
end
end
end
# ユーザに自動生成されたパスワードを設定します。
# @return [String]
def set_auto_generated_password
password = Devise.friendly_token[0..7]
self.password = password
self.password_confirmation = password
end
# ユーザが有効期限切れかどうかをチェックします。
# @return [Boolean]
def expired?
if expired_at
true if expired_at.beginning_of_day < Time.zone.now.beginning_of_day
end
end
# ユーザが管理者かどうかをチェックします。
# @return [Boolean]
def is_admin?
return true if has_role?("Administrator")
false
end
# ユーザがシステム上の最後のLibrarian権限ユーザかどうかをチェックします。
# @return [Boolean]
def last_librarian?
if has_role?("Librarian")
role = Role.find_by(name: "Librarian")
return true if role.users.count == 1
false
end
end
def send_confirmation_instructions
Devise::Mailer.confirmation_instructions(self).deliver if email.present?
end
# ユーザが削除可能かどうかをチェックします。
# @param [User] current_user ユーザ
# @return [Object]
def deletable_by?(current_user)
return nil unless current_user
if defined?(EnjuCirculation)
# 未返却の資料のあるユーザを削除しようとした
if checkouts.count.positive?
errors.add(:base, I18n.t("user.this_user_has_checked_out_item"))
end
end
if has_role?("Librarian")
# 管理者以外のユーザが図書館員を削除しようとした。図書館員の削除は管理者しかできない
unless current_user.has_role?("Administrator")
errors.add(:base, I18n.t("user.only_administrator_can_destroy"))
end
# 最後の図書館員を削除しようとした
if last_librarian?
errors.add(:base, I18n.t("user.last_librarian"))
end
end
# 最後の管理者を削除しようとした
if has_role?("Administrator")
if Role.find_by(name: "Administrator").users.count == 1
errors.add(:base, I18n.t("user.last_administrator"))
end
end
if errors[:base] == []
true
else
false
end
end
end
end
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0)
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :string(255)
# last_sign_in_ip :string(255)
# password_salt :string(255)
# confirmation_token :string(255)
# confirmed_at :datetime
# confirmation_sent_at :datetime
# unconfirmed_email :string(255)
# failed_attempts :integer default(0)
# unlock_token :string(255)
# locked_at :datetime
# authentication_token :string(255)
# created_at :datetime not null
# updated_at :datetime not null
# username :string(255) not null
# library_id :integer default(1), not null
# user_group_id :integer default(1), not null
# expired_at :datetime
# required_role_id :integer default(1), not null
# note :text
# keyword_list :text
# user_number :string(255)
# state :string(255)
# locale :string(255)
# enju_access_key :string(255)
# save_checkout_history :boolean
# checkout_icalendar_token :string(255)
# share_bookmarks :boolean
# save_search_history :boolean
# answer_feed_token :string(255)
#
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_nii/enju_manifestation.rb | app/models/concerns/enju_nii/enju_manifestation.rb | module EnjuNii
module EnjuManifestation
extend ActiveSupport::Concern
module ClassMethods
def import_from_cinii_books(options)
lisbn = ncid = nil
if options[:ncid]
ncid = options[:ncid]
manifestation = NcidRecord.find_by(body: ncid)&.manifestation
elsif options[:isbn]
lisbn = Lisbn.new(options[:isbn])
raise EnjuNii::InvalidIsbn unless lisbn.valid?
manifestation = Manifestation.find_by_isbn(lisbn.isbn)
end
return manifestation if manifestation.present?
doc = return_rdf(isbn: lisbn&.isbn, ncid: ncid)
raise EnjuNii::RecordNotFound unless doc
# raise EnjuNii::RecordNotFound if doc.at('//openSearch:totalResults').content.to_i == 0
import_record_from_cinii_books(doc)
end
def import_record_from_cinii_books(doc)
# http://ci.nii.ac.jp/info/ja/api/api_outline.html#cib_od
# return nil
ncid = doc.at("//cinii:ncid").try(:content)
identifier = NcidRecord.find_by(body: ncid)
return identifier.manifestation if identifier
creators = get_cinii_creator(doc)
publishers = get_cinii_publisher(doc)
# title
title = get_cinii_title(doc)
manifestation = Manifestation.new(title)
# date of publication
pub_date = doc.at("//dc:date").try(:content)
if pub_date
date = pub_date.split("-")
if date[0] && date[1]
date = sprintf("%04d-%02d", date[0], date[1])
else
date = pub_date
end
end
manifestation.pub_date = pub_date
manifestation.statement_of_responsibility = doc.at("//dc:creator").try(:content)
manifestation.extent = doc.at("//dcterms:extent").try(:content)
manifestation.dimensions = doc.at("//cinii:size").try(:content)
language = Language.find_by(iso_639_3: get_cinii_language(doc))
if language
manifestation.language_id = language.id
else
manifestation.language_id = 1
end
urn = doc.at("//dcterms:hasPart[@rdf:resource]")
if urn
urn = urn.attributes["resource"].value
if urn =~ /^urn:isbn/
isbn = Lisbn.new(urn.gsub(/^urn:isbn:/, "")).isbn
end
end
manifestation.carrier_type = CarrierType.find_by(name: "volume")
manifestation.manifestation_content_type = ContentType.find_by(name: "text")
if manifestation.valid?
Agent.transaction do
manifestation.save!
manifestation.create_ncid_record(body: ncid) if ncid.present?
manifestation.isbn_records.create(body: isbn) if isbn.present?
create_cinii_series_statements(doc, manifestation)
publisher_patrons = Agent.import_agents(publishers)
creator_patrons = Agent.import_agents(creators)
manifestation.publishers = publisher_patrons
manifestation.creators = creator_patrons
if defined?(EnjuSubject)
subjects = get_cinii_subjects(doc)
subject_heading_type = SubjectHeadingType.find_or_create_by!(name: "bsh")
subjects.each do |term|
subject = Subject.find_by(term: term[:term])
unless subject
subject = Subject.new(term)
subject.subject_heading_type = subject_heading_type
subject_type = SubjectType.find_or_create_by!(name: "concept")
subject.subject_type = subject_type
end
manifestation.subjects << subject
end
end
end
end
manifestation
end
def search_cinii_book(query, options = {})
options = { p: 1, count: 10, raw: false }.merge(options)
doc = nil
results = {}
startrecord = options[:idx].to_i
if startrecord == 0
startrecord = 1
end
url = "https://ci.nii.ac.jp/books/opensearch/search?q=#{CGI.escape(query)}&p=#{options[:p]}&count=#{options[:count]}&format=rss"
if options[:raw] == true
URI.parse(url).open.read
else
RSS::RDF::Channel.install_text_element("opensearch:totalResults", "http://a9.com/-/spec/opensearch/1.1/", "?", "totalResults", :text, "opensearch:totalResults")
RSS::BaseListener.install_get_text_element("http://a9.com/-/spec/opensearch/1.1/", "totalResults", "totalResults=")
RSS::Parser.parse(url, false)
end
end
def return_rdf(isbn: nil, ncid: nil)
if ncid
rss = self.search_cinii_opensearch(ncid: ncid)
elsif isbn
rss = self.search_cinii_opensearch(isbn: isbn)
if rss.channel.totalResults.to_i.zero?
rss = self.search_cinii_opensearch(isbn: cinii_normalize_isbn(isbn))
end
end
if rss.items.first
conn = Faraday.new("#{rss.items.first.link}.rdf") do |faraday|
faraday.adapter :net_http
end
Nokogiri::XML(conn.get.body)
end
end
def search_cinii_opensearch(ncid: nil, isbn: nil)
if ncid
url = "https://ci.nii.ac.jp/books/opensearch/search?ncid=#{ncid}&format=rss"
elsif isbn
url = "https://ci.nii.ac.jp/books/opensearch/search?isbn=#{isbn}&format=rss"
end
RSS::RDF::Channel.install_text_element("opensearch:totalResults", "http://a9.com/-/spec/opensearch/1.1/", "?", "totalResults", :text, "opensearch:totalResults")
RSS::BaseListener.install_get_text_element("http://a9.com/-/spec/opensearch/1.1/", "totalResults", "totalResults=")
RSS::Parser.parse(url, false)
end
private
def cinii_normalize_isbn(isbn)
if isbn.length == 10
Lisbn.new(isbn).isbn13
else
Lisbn.new(isbn).isbn10
end
end
def get_cinii_creator(doc)
doc.xpath("//foaf:maker/foaf:Person").map { |e|
{
full_name: e.at("./foaf:name").content&.strip,
full_name_transcription: e.xpath("./foaf:name[@xml:lang]").map { |n| n.content }.join("\n"),
patron_identifier: e.attributes["about"].try(:content)
}
}
end
def get_cinii_publisher(doc)
doc.xpath("//dc:publisher").map { |e| { full_name: e.content } }
end
def get_cinii_title(doc)
{
original_title: doc.at("//dc:title[not(@xml:lang)]").children.first.content,
title_transcription: doc.xpath("//dc:title[@xml:lang]", 'dc': "http://purl.org/dc/elements/1.1/").map { |e| e.try(:content) }.join("\n"),
title_alternative: doc.xpath("//dcterms:alternative").map { |e| e.try(:content) }.join("\n")
}
end
def get_cinii_language(doc)
language = doc.at("//dc:language").try(:content)
if language.size > 3
language[0..2]
else
language
end
end
def get_cinii_subjects(doc)
subjects = []
doc.xpath("//foaf:topic").each do |s|
subjects << { term: s["dc:title"] }
end
subjects
end
def create_cinii_series_statements(doc, manifestation)
series = doc.at("//dcterms:isPartOf")
if series && parent_url = series["rdf:resource"]
ptbl = series["dc:title"]
rdf_url = "#{URI.parse(parent_url.gsub(/\#\w+\Z/, '')).to_s}"
conn = Faraday.new("#{rdf_url}.rdf") do |faraday|
faraday.adapter :net_http
end
parent_doc = Nokogiri::XML(conn.get.body)
parent_titles = get_cinii_title(parent_doc)
series_statement = SeriesStatement.new(parent_titles)
series_statement.series_statement_identifier = rdf_url
manifestation.series_statements << series_statement
if parts = ptbl.split(/ \. /)
parts[1..-1].each do |part|
title, volume_number, = part.split(/ ; /)
original_title, title_transcription, = title.split(/\|\|/)
series_statement = SeriesStatement.new(
original_title: original_title,
title_transcription: title_transcription,
volume_number_string: volume_number
)
manifestation.series_statements << series_statement
end
end
end
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_subject/enju_manifestation.rb | app/models/concerns/enju_subject/enju_manifestation.rb | module EnjuSubject
module EnjuManifestation
extend ActiveSupport::Concern
included do
has_many :subjects, dependent: :destroy
has_many :classifications, dependent: :destroy
accepts_nested_attributes_for :subjects, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :classifications, allow_destroy: true, reject_if: :all_blank
after_save do
subject_index!
end
after_destroy do
subject_index!
end
searchable do
text :subject do
subjects.map { |s| [ s.term, s.term_transcription ] }.flatten.compact
end
string :subject, multiple: true do
subjects.map { |s| [ s.term, s.term_transcription ] }.flatten.compact
end
string :classification, multiple: true do
classifications.map { |c| "#{c.classification_type.name}_#{c.category}" }
end
integer :subject_ids, multiple: true
end
end
def subject_index!
subjects.map(&:index)
classifications.map(&:index)
Sunspot.commit
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_ndl/enju_agent.rb | app/models/concerns/enju_ndl/enju_agent.rb | # frozen_string_literal: true
module EnjuNdl
module EnjuAgent
extend ActiveSupport::Concern
included do
has_one :ndla_record
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_ndl/enju_manifestation.rb | app/models/concerns/enju_ndl/enju_manifestation.rb | module EnjuNdl
module EnjuManifestation
extend ActiveSupport::Concern
module ClassMethods
def import_isbn(isbn)
manifestation = Manifestation.import_from_ndl_search(isbn: isbn)
manifestation
end
def ndl_bib_doc(ndl_bib_id)
url = "https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&version=1.2&query=itemno=#{ndl_bib_id}&recordSchema=dcndl&onlyBib=true"
Nokogiri::XML(Nokogiri::XML(URI.parse(url).read).at("//xmlns:recordData").content)
end
# Use http://www.ndl.go.jp/jp/dlib/standards/opendataset/aboutIDList.txt
def import_ndl_bib_id(ndl_bib_id)
import_record(ndl_bib_doc(ndl_bib_id))
end
def import_from_ndl_search(options)
manifestation = isbn = nil
if options[:jpno]
manifestation = JpnoRecord.find_by(body: options[:jpno])&.manifestation
elsif options[:isbn]
lisbn = Lisbn.new(options[:isbn])
raise EnjuNdl::InvalidIsbn unless lisbn.valid?
isbn = lisbn.isbn13
manifestation = Manifestation.find_by_isbn(isbn)
end
return manifestation if manifestation
doc = return_xml(jpno: options[:jpno], isbn: isbn)
raise EnjuNdl::RecordNotFound unless doc
# raise EnjuNdl::RecordNotFound if doc.at('//openSearch:totalResults').content.to_i == 0
import_record(doc)
end
def import_record(doc)
iss_itemno = URI.parse(doc.at("//dcndl:BibAdminResource[@rdf:about]").values.first).path.split("/").last
ndl_bib_id_record =NdlBibIdRecord.find_by(body: iss_itemno)
return ndl_bib_id_record.manifestation if ndl_bib_id_record
jpno = doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/JPNO"]').try(:content)
publishers = get_publishers(doc)
# title
title = get_title(doc)
# date of publication
pub_date = doc.at("//dcterms:issued").try(:content).to_s.tr(".", "-")
pub_date = nil unless pub_date =~ /^\d+(-\d{0,2}){0,2}$/
if pub_date
date = pub_date.split("-")
date = if date[0] && date[1]
format("%04d-%02d", date[0], date[1])
else
pub_date
end
end
language = Language.find_by(iso_639_2: get_language(doc))
language_id = if language
language.id
else
1
end
isbn = Lisbn.new(doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/ISBN"]').try(:content).to_s).try(:isbn)
issn = StdNum::ISSN.normalize(doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/ISSN"]').try(:content))
issn_l = StdNum::ISSN.normalize(doc.at('//dcterms:identifier[@rdf:datatype="http://ndl.go.jp/dcndl/terms/ISSNL"]').try(:content))
carrier_type = content_type = nil
is_serial = nil
doc.xpath("//dcndl:materialType[@rdf:resource]").each do |d|
case d.attributes["resource"].try(:content)
when "http://ndl.go.jp/ndltype/Book"
carrier_type = CarrierType.find_by(name: "print")
content_type = ContentType.find_by(name: "text")
when "http://ndl.go.jp/ndltype/Braille"
content_type = ContentType.find_by(name: "tactile_text")
# when 'http://ndl.go.jp/ndltype/ComputerProgram'
# content_type = ContentType.find_by(name: 'computer_program')
when "http://ndl.go.jp/ndltype/ElectronicResource"
carrier_type = CarrierType.find_by(name: "file")
when "http://ndl.go.jp/ndltype/Journal"
is_serial = true
when "http://ndl.go.jp/ndltype/Map"
content_type = ContentType.find_by(name: "cartographic_image")
when "http://ndl.go.jp/ndltype/Music"
content_type = ContentType.find_by(name: "performed_music")
when "http://ndl.go.jp/ndltype/MusicScore"
content_type = ContentType.find_by(name: "notated_music")
when "http://ndl.go.jp/ndltype/Painting"
content_type = ContentType.find_by(name: "still_image")
when "http://ndl.go.jp/ndltype/Photograph"
content_type = ContentType.find_by(name: "still_image")
when "http://ndl.go.jp/ndltype/PicturePostcard"
content_type = ContentType.find_by(name: "still_image")
when "http://purl.org/dc/dcmitype/MovingImage"
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "http://purl.org/dc/dcmitype/Sound"
content_type = ContentType.find_by(name: "sounds")
when "http://purl.org/dc/dcmitype/StillImage"
content_type = ContentType.find_by(name: "still_image")
end
# NDLサーチのmaterialTypeは複数設定されているが、
# content_typeはその最初の1件を用いて取得する
break if content_type
end
admin_identifier = doc.at("//dcndl:BibAdminResource[@rdf:about]").attributes["about"].value
description = doc.at("//dcterms:abstract").try(:content)
price = doc.at("//dcndl:price").try(:content)
volume_number_string = doc.at("//dcndl:volume/rdf:Description/rdf:value").try(:content)
extent = get_extent(doc)
publication_periodicity = doc.at("//dcndl:publicationPeriodicity").try(:content)
statement_of_responsibility = doc.xpath("//dcndl:BibResource/dc:creator").map(&:content).join("; ")
publication_place = doc.at("//dcterms:publisher/foaf:Agent/dcndl:location").try(:content)
edition_string = doc.at("//dcndl:edition").try(:content)
manifestation = Manifestation.find_by(manifestation_identifier: admin_identifier)
return manifestation if manifestation
Agent.transaction do
publisher_agents = Agent.import_agents(publishers)
manifestation = Manifestation.new(
manifestation_identifier: admin_identifier,
original_title: title[:manifestation],
title_transcription: title[:transcription],
title_alternative: title[:alternative],
title_alternative_transcription: title[:alternative_transcription],
# TODO: NDLサーチに入っている図書以外の資料を調べる
# :carrier_type_id => CarrierType.find_by(name: 'print').id,
language_id: language_id,
pub_date: date,
description: description,
volume_number_string: volume_number_string,
price: price,
statement_of_responsibility: statement_of_responsibility,
start_page: extent[:start_page],
end_page: extent[:end_page],
height: extent[:height],
extent: extent[:extent],
dimensions: extent[:dimensions],
publication_place: publication_place,
edition_string: edition_string
)
manifestation.serial = true if is_serial
manifestation.carrier_type = carrier_type if carrier_type
manifestation.manifestation_content_type = content_type if content_type
if manifestation.save
manifestation.isbn_records.find_or_create_by(body: isbn) if isbn.present?
manifestation.issn_records.find_or_create_by(body: issn) if issn.present?
manifestation.issn_records.find_or_create_by(body: issn_l) if issn_l.present?
manifestation.create_jpno_record(body: jpno) if jpno.present?
manifestation.create_ndl_bib_id_record(body: iss_itemno) if iss_itemno.present?
manifestation.publishers << publisher_agents
create_additional_attributes(doc, manifestation)
if is_serial
series_statement = SeriesStatement.new(
original_title: title[:manifestation],
title_alternative: title[:alternative],
title_transcription: title[:transcription],
series_master: true
)
if series_statement.valid?
manifestation.series_statements << series_statement
end
else
create_series_statement(doc, manifestation)
end
end
end
# manifestation.send_later(:create_frbr_instance, doc.to_s)
manifestation
end
def create_additional_attributes(doc, manifestation)
title = get_title(doc)
creators = get_creators(doc).uniq
subjects = get_subjects(doc).uniq
classifications = get_classifications(doc).uniq
classification_urls = doc.xpath("//dcterms:subject[@rdf:resource]").map { |subject| subject.attributes["resource"].value }
Agent.transaction do
creator_agents = Agent.import_agents(creators)
content_type_id = begin
ContentType.find_by(name: "text").id
rescue StandardError
1
end
manifestation.creators << creator_agents
if defined?(EnjuSubject)
subject_heading_type = SubjectHeadingType.find_or_create_by!(name: "ndlsh")
subjects.each do |term|
subject = Subject.find_by(term: term[:term])
unless subject
subject = Subject.new(term)
subject.subject_heading_type = subject_heading_type
subject.subject_type = SubjectType.find_or_create_by!(name: "concept")
end
# if subject.valid?
manifestation.subjects << subject
# end
# subject.save!
end
if classification_urls
classification_urls.each do |url|
begin
ndc_url = URI.parse(url)
rescue URI::InvalidURIError
end
next unless ndc_url
ndc_type = ndc_url.path.split("/").reverse[1]
next unless (ndc_type == "ndc9") || (ndc_type == "ndc10")
ndc = ndc_url.path.split("/").last
classification_type = ClassificationType.find_or_create_by!(name: ndc_type)
classification = Classification.new(category: ndc)
classification.classification_type = classification_type
manifestation.classifications << classification if classification.valid?
end
end
ndc8 = doc.xpath('//dc:subject[@rdf:datatype="http://ndl.go.jp/dcndl/terms/NDC8"]').first
if ndc8
classification_type = ClassificationType.find_or_create_by!(name: "ndc8")
classification = Classification.new(category: ndc8.content)
classification.classification_type = classification_type
manifestation.classifications << classification if classification.valid?
end
end
end
end
def search_ndl(query, options = {})
options = { dpid: "iss-ndl-opac", item: "any", idx: 1, per_page: 10, raw: false, mediatype: "books periodicals video audio scores" }.merge(options)
doc = nil
results = {}
startrecord = options[:idx].to_i
startrecord = 1 if startrecord.zero?
url = "https://ndlsearch.ndl.go.jp/api/opensearch?dpid=#{options[:dpid]}&#{options[:item]}=#{format_query(query)}&cnt=#{options[:per_page]}&idx=#{startrecord}&mediatype=#{options[:mediatype]}"
if options[:raw] == true
URI.parse(url).read
else
RSS::Rss::Channel.install_text_element("openSearch:totalResults", "http://a9.com/-/spec/opensearchrss/1.0/", "?", "totalResults", :text, "openSearch:totalResults")
RSS::BaseListener.install_get_text_element "http://a9.com/-/spec/opensearchrss/1.0/", "totalResults", "totalResults="
RSS::Parser.parse(url, false)
end
end
def normalize_isbn(isbn)
if isbn.length == 10
Lisbn.new(isbn).isbn13
else
Lisbn.new(isbn).isbn10
end
end
def return_xml(isbn: nil, jpno: nil)
if jpno.present?
url = "https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&version=1.2&query=jpno=#{jpno}&recordSchema=dcndl&onlyBib=true"
elsif isbn.present?
url = "https://ndlsearch.ndl.go.jp/api/sru?operation=searchRetrieve&version=1.2&query=isbn=#{isbn}&recordSchema=dcndl&onlyBib=true"
else
return
end
response = Nokogiri::XML(URI.parse(url).read).at("//xmlns:recordData")&.content
Nokogiri::XML(response) if response
end
private
def get_title(doc)
title = {
manifestation: doc.xpath("//dc:title/rdf:Description/rdf:value").collect(&:content).join(" "),
transcription: doc.xpath("//dc:title/rdf:Description/dcndl:transcription").collect(&:content).join(" "),
alternative: doc.at("//dcndl:alternative/rdf:Description/rdf:value").try(:content),
alternative_transcription: doc.at("//dcndl:alternative/rdf:Description/dcndl:transcription").try(:content)
}
volumeTitle = doc.at("//dcndl:volumeTitle/rdf:Description/rdf:value").try(:content)
volumeTitle_transcription = doc.at("//dcndl:volumeTitle/rdf:Description/dcndl:transcription").try(:content)
title[:manifestation] << " #{volumeTitle}" if volumeTitle
title[:transcription] << " #{volumeTitle_transcription}" if volumeTitle_transcription
title
end
def get_creators(doc)
creators = []
doc.xpath("//dcterms:creator/foaf:Agent").each do |creator|
creators << {
full_name: creator.at("./foaf:name").content,
full_name_transcription: creator.at("./dcndl:transcription").try(:content),
ndla_identifier: creator.attributes["about"].try(:content)
}
end
creators
end
def get_subjects(doc)
subjects = []
doc.xpath("//dcterms:subject/rdf:Description").each do |subject|
subjects << {
term: subject.at("./rdf:value").content,
# :url => subject.attribute('about').try(:content)
}
end
subjects
end
def get_classifications(doc)
classifications = []
doc.xpath("//dcterms:subject[@rdf:resource]").each do |classification|
classifications << {
url: classification.attributes["resource"].content
}
end
classifications
end
def get_language(doc)
# TODO: 言語が複数ある場合
language = doc.at('//dcterms:language[@rdf:datatype="http://purl.org/dc/terms/ISO639-2"]').try(:content)
language.downcase if language
end
def get_publishers(doc)
publishers = []
doc.xpath("//dcterms:publisher/foaf:Agent").each do |publisher|
publishers << {
full_name: publisher.at("./foaf:name").content,
full_name_transcription: publisher.at("./dcndl:transcription").try(:content),
agent_identifier: publisher.attributes["about"].try(:content)
}
end
publishers
end
def get_extent(doc)
extent = doc.at("//dcterms:extent").try(:content)
value = { start_page: nil, end_page: nil, height: nil }
if extent
extent = extent.split(";")
page = extent[0].try(:strip)
value[:extent] = page
if page =~ /\d+p/
value[:start_page] = 1
value[:end_page] = page.to_i
end
height = extent[1].try(:strip)
value[:dimensions] = height
value[:height] = height.to_i if height =~ /\d+cm/
end
value
end
def create_series_statement(doc, manifestation)
series = series_title = {}
series[:title] = doc.at("//dcndl:seriesTitle/rdf:Description/rdf:value").try(:content)
series[:title_transcription] = doc.at("//dcndl:seriesTitle/rdf:Description/dcndl:transcription").try(:content)
series[:creator] = doc.at("//dcndl:seriesCreator").try(:content)
if series[:title]
series_title[:title] = series[:title].split(";")[0].strip
if series[:title_transcription]
series_title[:title_transcription] = series[:title_transcription].split(";")[0].strip
end
end
if series_title[:title]
series_statement = SeriesStatement.find_by(original_title: series_title[:title])
series_statement ||= SeriesStatement.new(
original_title: series_title[:title],
title_transcription: series_title[:title_transcription],
creator_string: series[:creator]
)
end
if series_statement.try(:save)
manifestation.series_statements << series_statement
end
manifestation
end
def format_query(query)
Addressable::URI.encode(query.to_s.tr(" ", " "))
end
end
class AlreadyImported < StandardError
end
end
class RecordNotFound < StandardError
end
class InvalidIsbn < StandardError
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_message/enju_user.rb | app/models/concerns/enju_message/enju_user.rb | module EnjuMessage
module EnjuUser
extend ActiveSupport::Concern
included do
has_many :sent_messages, foreign_key: "sender_id", class_name: "Message", inverse_of: :sender, dependent: :nullify
has_many :received_messages, foreign_key: "receiver_id", class_name: "Message", inverse_of: :receiver, dependent: :nullify
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb | app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb | module EnjuManifestationViewer
module EnjuManifestation
extend ActiveSupport::Concern
def youtube_id
if access_address
url = ::Addressable::URI.parse(access_address)
if url.host =~ /youtube\.com$/ && (url.path == "/watch")
CGI.parse(url.query)["v"][0]
end
end
end
def nicovideo_id
if access_address
url = ::Addressable::URI.parse(access_address)
if url.host =~ /nicovideo\.jp$/ && url.path =~ /^\/watch/
url.path.split("/")[2]
end
end
end
def flickr
if access_address
url = ::Addressable::URI.parse(access_address)
paths = url.path.split("/")
if url.host =~ /^www\.flickr\.com$/ && (paths[1] == "photos") && paths[2]
info = {}
if paths[3] == "sets"
info[:user] = paths[2]
info[:set_id] = paths[4]
info
end
end
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_inventory/enju_item.rb | app/models/concerns/enju_inventory/enju_item.rb | module EnjuInventory
module EnjuItem
extend ActiveSupport::Concern
included do
has_many :inventories, dependent: :destroy
has_many :inventory_files, through: :inventories
searchable do
integer :inventory_file_ids, multiple: true
end
def self.inventory_items(inventory_file, mode = "not_on_shelf")
item_ids = Item.pluck(:id)
inventory_item_ids = inventory_file.items.pluck("items.id")
case mode
when "not_on_shelf"
Item.where(id: (item_ids - inventory_item_ids))
when "not_in_catalog"
Item.where(id: (inventory_item_ids - item_ids))
end
rescue StandardError
nil
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_bookmark/enju_user.rb | app/models/concerns/enju_bookmark/enju_user.rb | module EnjuBookmark
module EnjuUser
extend ActiveSupport::Concern
included do
has_many :bookmarks, dependent: :destroy
acts_as_tagger
end
def owned_tags_by_solr
bookmark_ids = bookmarks.collect(&:id)
if bookmark_ids.empty?
[]
else
Tag.bookmarked(bookmark_ids)
end
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_bookmark/enju_manifestation.rb | app/models/concerns/enju_bookmark/enju_manifestation.rb | module EnjuBookmark
module EnjuManifestation
extend ActiveSupport::Concern
included do
has_many :bookmarks, dependent: :destroy, foreign_key: :manifestation_id, inverse_of: :manifestation
has_many :users, through: :bookmarks
searchable do
string :tag, multiple: true do
bookmarks.map { |bookmark| bookmark.tag_list }.flatten
end
text :tag do
bookmarks.map { |bookmark| bookmark.tag_list }.flatten
end
end
end
def bookmarked?(user)
return true if user.bookmarks.where(url: url).first
false
end
def tags
bookmarks.map { |bookmark| bookmark.tags }.flatten
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_event/enju_library.rb | app/models/concerns/enju_event/enju_library.rb | module EnjuEvent
module EnjuLibrary
extend ActiveSupport::Concern
included do
has_many :events, dependent: :destroy
end
def closed?(date)
events.closing_days.map { |c|
c.start_at.beginning_of_day
}.include?(date.beginning_of_day)
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_library/enju_item.rb | app/models/concerns/enju_library/enju_item.rb | module EnjuLibrary
module EnjuItem
extend ActiveSupport::Concern
included do
has_one :accept
scope :accepted_between, lambda { |from, to| includes(:accept).where("items.created_at BETWEEN ? AND ?", Time.zone.parse(from).beginning_of_day, Time.zone.parse(to).end_of_day) }
belongs_to :shelf, counter_cache: true
searchable do
string :library do
shelf.library.name if shelf
end
end
end
def shelf_name
shelf.name
end
def hold?(library)
return true if shelf.library == library
false
end
def library_url
"#{LibraryGroup.site_config.url}libraries/#{shelf.library.name}"
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/models/concerns/enju_loc/enju_manifestation.rb | app/models/concerns/enju_loc/enju_manifestation.rb | module EnjuLoc
module EnjuManifestation
extend ActiveSupport::Concern
included do
def self.loc_search(query, options = {})
options = {}.merge(options)
doc = nil
results = {}
startrecord = options[:idx].to_i
if startrecord == 0
startrecord = 1
end
url = LOC_SRU_BASEURL + "?operation=searchRetrieve&version=1.1&=query=#{URI.escape(query)}"
cont = Faraday.get(url).body
parser = LibXML::XML::Parser.string(cont)
doc = parser.parse
end
def self.import_record_from_loc_isbn(options)
# if options[:isbn]
lisbn = Lisbn.new(options[:isbn])
raise EnjuLoc::InvalidIsbn unless lisbn.valid?
# end
manifestation = Manifestation.find_by_isbn(lisbn.isbn)
return manifestation.first if manifestation.present?
doc = return_xml(lisbn.isbn)
raise EnjuLoc::RecordNotFound unless doc
import_record_from_loc(doc)
end
NS = { "mods" => "http://www.loc.gov/mods/v3" }
def self.import_record_from_loc(doc)
record_identifier = doc.at("//mods:recordInfo/mods:recordIdentifier", NS).try(:content)
identifier_type = IdentifierType.find_by(name: "loc_identifier")
identifier_type ||= IdentifierType.create!(name: "loc_identifier")
loc_identifier = Identifier.find_by(body: record_identifier, identifier_type_id: identifier_type.id)
return loc_identifier.manifestation if loc_identifier
publishers = []
doc.xpath("//mods:publisher", NS).each do |publisher|
publishers << {
full_name: publisher.content,
# :agent_identifier => publisher.attributes["about"].try(:content)
}
end
creators = get_mods_creators(doc)
# title
titles = get_mods_titles(doc)
# date of publication
date = get_mods_date_of_publication(doc)
language = Language.find_by(iso_639_2: get_mods_language(doc))
if language
language_id = language.id
else
language_id = 1
end
isbn = Lisbn.new(doc.at('/mods:mods/mods:identifier[@type="isbn"]', NS).try(:content).to_s).try(:isbn)
lccn = StdNum::LCCN.normalize(doc.at('/mods:mods/mods:identifier[@type="lccn"]', NS).try(:content).to_s)
issn = StdNum::ISSN.normalize(doc.at('/mods:mods/mods:identifier[@type="issn"]', NS).try(:content).to_s)
issn_l = StdNum::ISSN.normalize(doc.at('/mods:mods/mods:identifier[@type="issn-l"]', NS).try(:content).to_s)
types = get_mods_carrier_and_content_types(doc)
content_type = types[:content_type]
carrier_type = types[:carrier_type]
record_identifier = doc.at("//mods:recordInfo/mods:recordIdentifier", NS).try(:content)
description = doc.xpath("//mods:abstract", NS).collect(&:content).join("\n")
edition_string = doc.at("//mods:edition", NS).try(:content)
extent = get_mods_extent(doc)
note = get_mods_note(doc)
frequency = get_mods_frequency(doc)
issuance = doc.at("//mods:issuance", NS).try(:content)
is_serial = true if issuance == "serial"
statement_of_responsibility = get_mods_statement_of_responsibility(doc)
access_address = get_mods_access_address(doc)
publication_place = get_mods_publication_place(doc)
manifestation = nil
Agent.transaction do
creator_agents = Agent.import_agents(creators)
publisher_agents = Agent.import_agents(publishers)
manifestation = Manifestation.new(
manifestation_identifier: record_identifier,
original_title: titles[:original_title],
title_alternative: titles[:title_alternative],
language_id: language_id,
pub_date: date,
description: description,
edition_string: edition_string,
statement_of_responsibility: statement_of_responsibility,
start_page: extent[:start_page],
end_page: extent[:end_page],
extent: extent[:extent],
height: extent[:height],
dimensions: extent[:dimensions],
access_address: access_address,
note: note,
publication_place: publication_place,
serial: is_serial
)
identifier = {}
if loc_identifier
identifier[:loc_identifier] = Identifier.new(
manifestation: manifestation,
body: loc_identifier,
identifier_type: IdentifierType.find_by(name: "loc_identifier") || IdentifierType.create!(name: "loc_identifier")
)
end
if issn_l
identifier[:issn_l] = Identifier.new(
manifestation: manifestation,
body: issn_l,
identifier_type: IdentifierType.find_by(name: "issn_l") || IdentifierType.create!(name: "issn_l")
)
end
manifestation.carrier_type = carrier_type if carrier_type
manifestation.manifestation_content_type = content_type if content_type
manifestation.frequency = frequency if frequency
manifestation.save!
identifier.each do |k, v|
manifestation.identifiers << v if v.valid?
end
manifestation.isbn_records.create(body: isbn) if isbn.present?
manifestation.issn_records.create(body: issn) if issn.present?
manifestation.create_lccn_record(body: lccn) if lccn.present?
manifestation.publishers << publisher_agents
manifestation.creators << creator_agents
create_loc_subject_related_elements(doc, manifestation)
create_loc_series_statement(doc, manifestation)
if is_serial
create_loc_series_master(doc, manifestation)
end
end
manifestation
end
private
def self.create_loc_subject_related_elements(doc, manifestation)
subjects = get_mods_subjects(doc)
classifications = get_mods_classifications(doc)
if defined?(EnjuSubject)
subject_heading_type = SubjectHeadingType.find_by(name: "lcsh") || SubjectHeadingType.create!(name: "lcsh")
subjects.each do |term|
subject = Subject.find_by(term: term[:term])
unless subject
subject = Subject.new(term)
subject.subject_heading_type = subject_heading_type
subject.subject_type = SubjectType.find_by(name: "concept") || SubjectType.create!(name: "concept")
end
manifestation.subjects << subject
end
if classifications
classification_type = ClassificationType.find_by(name: "ddc") || ClassificationType.create!(name: "ddc")
classifications.each do |ddc|
classification = Classification.find_by(category: ddc)
unless classification
classification = Classification.new(category: ddc)
classification.classification_type = classification_type
end
manifestation.classifications << classification
end
end
end
end
def self.create_loc_series_statement(doc, manifestation)
doc.xpath('//mods:relatedItem[@type="series"]/mods:titleInfo/mods:title', NS).each do |series|
series_title = title = series.try(:content)
if title
series_title = title.split(";")[0].strip
end
next unless series_title
series_statement = SeriesStatement.find_by(original_title: series_title) || SeriesStatement.create!(original_title: series_title)
if series_statement.try(:save)
manifestation.series_statements << series_statement
end
end
end
def self.create_loc_series_master(doc, manifestation)
titles = get_mods_titles(doc)
series_statement = SeriesStatement.new(
original_title: titles[:original_title],
title_alternative: titles[:title_alternative],
series_master: true
)
if series_statement.try(:save)
manifestation.series_statements << series_statement
end
end
def self.get_mods_titles(doc)
original_title = ""
title_alternatives = []
doc.xpath("//mods:mods/mods:titleInfo", NS).each do |e|
type = e.attributes["type"].try(:content)
case type
when "alternative", "translated", "abbreviated", "uniform"
title_alternatives << e.at("./mods:title", NS).content
else
nonsort = e.at("./mods:nonSort", NS).try(:content)
original_title << nonsort if nonsort
original_title << e.at("./mods:title", NS).try(:content)
subtitle = e.at("./mods:subTitle", NS).try(:content)
original_title << " : #{subtitle}" if subtitle
partnumber = e.at("./mods:partNumber", NS).try(:content)
partname = e.at("./mods:partName", NS).try(:content)
partname = [ partnumber, partname ].compact.join(": ")
original_title << ". #{partname}" if partname.present?
end
end
{ original_title: original_title, title_alternative: title_alternatives.join(" ; ") }
end
def self.get_mods_language(doc)
language = doc.at('//mods:language/mods:languageTerm[@authority="iso639-2b"]', NS).try(:content)
end
def self.get_mods_access_address(doc)
access_address = nil
url = doc.at("//mods:location/mods:url", NS)
if url
usage = url.attributes["usage"].try(:content)
case usage
when "primary display", "primary"
access_address = url.try(:content)
end
end
access_address
end
def self.get_mods_publication_place(doc)
place = doc.at('//mods:originInfo/mods:place/mods:placeTerm[@type="text"]', NS).try(:content)
end
def self.get_mods_extent(doc)
extent = doc.at("//mods:extent", NS).try(:content)
value = { start_page: nil, end_page: nil, height: nil }
if extent
extent = extent.split(";")
page = extent[0].try(:strip)
value[:extent] = page
if page =~ /(\d+)\s*(p|page)/
value[:start_page] = 1
value[:end_page] = $1.dup.to_i
end
height = extent[1].try(:strip)
value[:dimensions] = height
if height =~ /(\d+)\s*cm/
value[:height] = $1.dup.to_i
end
end
value
end
def self.get_mods_statement_of_responsibility(doc)
note = doc.at('//mods:note[@type="statement of responsibility"]', NS).try(:content)
if note.blank?
note = get_mods_creators(doc).map { |e| e[:full_name] }.join(" ; ")
end
note
end
def self.get_mods_note(doc)
notes = []
doc.xpath("//mods:note", NS).each do |note|
type = note.attributes["type"].try(:content)
next if type == "statement of responsibility"
note_s = note.try(:content)
notes << note_s if note_s.present?
end
if notes.empty?
nil
else
notes.join(";\n")
end
end
def self.get_mods_date_of_publication(doc)
dates = []
doc.xpath("//mods:dateIssued", NS).each do |pub_date|
pub_date = pub_date.content.sub(/\A[cp]/, "")
next unless pub_date =~ /^\d+(-\d\d?){0,2}$/
date = pub_date.split("-")
if date[0] and date[1]
dates << sprintf("%04d-%02d", date[0], date[1])
else
dates << pub_date
end
end
dates.compact.first
end
# derived from marcfrequency: http://www.loc.gov/standards/valuelist/marcfrequency.html
MARCFREQUENCY = [
"Continuously updated",
"Daily",
"Semiweekly",
"Three times a week",
"Weekly",
"Biweekly",
"Three times a month",
"Semimonthly",
"Monthly",
"Bimonthly",
"Quarterly",
"Three times a year",
"Semiannual",
"Annual",
"Biennial",
"Triennial",
"Completely irregular"
]
def self.get_mods_frequency(doc)
frequencies = []
doc.xpath("//mods:frequency", NS).each do |freq|
frequency = freq.try(:content)
MARCFREQUENCY.each do |freq_regex|
if /\A(#{freq_regex})/ =~ frequency
frequency_name = freq_regex.downcase.gsub(/\s+/, "_")
frequencies << Frequency.find_by(name: frequency_name)
end
end
end
frequencies.compact.first
end
def self.get_mods_creators(doc)
creators = []
doc.xpath("/mods:mods/mods:name", NS).each do |creator|
creators << {
full_name: creator.xpath("./mods:namePart", NS).collect(&:content).join(", ")
}
end
creators.uniq
end
# TODO:only LCSH-based parsing...
def self.get_mods_subjects(doc)
subjects = []
doc.xpath('//mods:subject[@authority="lcsh"]', NS).each do |s|
subject = []
s.xpath("./*", NS).each do |subelement|
type = subelement.name
case subelement.name
when "topic", "geographic", "genre", "temporal"
subject << { type: type, term: subelement.try(:content) }
when "titleInfo"
subject << { type: type, term: subelement.at("./mods:title", NS).try(:content) }
when "name"
name = subelement.xpath("./mods:namePart", NS).map { |e| e.try(:content) }.join(", ")
subject << { type: type, term: name }
end
end
next if subject.compact.empty?
if subject.size > 1 and subject[0][:type] == "name" and subject[1][:type] == "titleInfo"
subject[0..1] = { term: subject[0..1].map { |e|e[:term] }.join(". ") }
end
subjects << {
term: subject.map { |e|e[:term] }.compact.join("--")
}
end
subjects
end
# TODO:support only DDC.
def self.get_mods_classifications(doc)
classifications = []
doc.xpath('//mods:classification[@authority="ddc"]', NS).each do |c|
ddc = c.content
if ddc
classifications << ddc.split(/[^\d\.]/).first.try(:strip)
end
end
classifications.compact
end
def self.get_mods_carrier_and_content_types(doc)
carrier_type = content_type = nil
doc.xpath("//mods:form", NS).each do |e|
authority = e.attributes["authority"].try(:content)
case authority
when "gmd"
case e.content
when "electronic resource"
carrier_type = CarrierType.find_by(name: "online_resource")
when "videorecording", "motion picture", "game"
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "sound recording"
content_type = ContentType.find_by(name: "performed_music")
when "graphic", "picture"
content_type = ContentType.find_by(name: "still_image")
# TODO: Enju needs more specific mappings...
when "art original",
"microscope slides",
"art reproduction",
"model",
"chart",
"diorama",
"realia",
"filmstrip",
"slide",
"flash card",
"technical drawing",
"toy",
"kit",
"transparency",
"microform"
content_type = ContentType.find_by(name: "other")
end
when "marcsmd" # cf.http://www.loc.gov/standards/valuelist/marcsmd.html
case e.content
when "text", "large print", "regular print", "text in looseleaf binder"
carrier_type = CarrierType.find_by(name: "volume")
content_type = ContentType.find_by(name: "text")
when "braille"
carrier_type = CarrierType.find_by(name: "volume")
content_type = ContentType.find_by(name: "tactile_text")
when "videodisc"
carrier_type = CarrierType.find_by(name: "videodisc")
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "videorecording", "videocartridge", "videocassette", "videoreel"
carrier_type = CarrierType.find_by(name: "other")
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "electronic resource"
carrier_type = CarrierType.find_by(name: "online_resource")
when "chip cartridge", "computer optical disc cartridge", "magnetic disk", "magneto-optical disc", "optical disc", "remote", "tape cartridge", "tape cassette", "tape reel"
# carrier_type = CarrierType.find_by(name: 'other')
when "motion picture", "film cartridge", "film cassette", "film reel"
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "sound recording", "cylinder", "roll", "sound cartridge", "sound cassette", "sound-tape reel", "sound-track film", "wire recording"
content_type = ContentType.find_by(name: "performed_music")
when "sound disc"
content_type = ContentType.find_by(name: "performed_music")
carrier_type = CarrierType.find_by(name: "audio_disc")
when "nonprojected graphic", "chart", "collage", "drawing", "flash card", "painting", "photomechanical print", "photonegative", "photoprint", "picture", "print", "technical drawing", "projected graphic", "filmslip", "filmstrip cartridge", "filmstrip roll", "other filmstrip type ", "slide", "transparency"
content_type = ContentType.find_by(name: "still_image")
when "tactile material", "braille", "tactile, with no writing system"
content_type = ContentType.find_by(name: "tactile_text")
# TODO: Enju needs more specific mappings...
when "globe",
"celestial globe",
"earth moon globe",
"planetary or lunar globe",
"terrestrial globe",
"map",
"atlas",
"diagram",
"map",
"model",
"profile",
"remote-sensing image",
"section",
"view",
"microform",
"aperture card",
"microfiche",
"microfiche cassette",
"microfilm cartridge",
"microfilm cassette",
"microfilm reel",
"microopaque",
"combination",
"moon"
content_type = ContentType.find_by(name: "other")
end
when "marcform" # cf. http://www.loc.gov/standards/valuelist/marcform.html
case e.content
when "print", "large print"
carrier_type = CarrierType.find_by(name: "volume")
content_type = ContentType.find_by(name: "text")
when "electronic"
carrier_type = CarrierType.find_by(name: "online_resource")
when "braille"
content_type = ContentType.find_by(name: "tactile_text")
# TODO: Enju needs more specific mappings...
when "microfiche", "microfilm"
content_type = ContentType.find_by(name: "other")
end
end
end
doc.xpath("//mods:genre", NS).each do |e|
authority = e.attributes["authority"].try(:content)
case authority
when "rdacontent"
content_type = ContentType.find_by(name: e.content.gsub(/\W+/, "_"))
content_type ||= ContentType.find_by(name: "other")
end
end
type = doc.at("//mods:typeOfResource", NS).try(:content)
case type
when "text"
content_type = ContentType.find_by(name: "text")
when "sound recording"
content_type = ContentType.find_by(name: "sounds")
when "sound recording-musical"
content_type = ContentType.find_by(name: "performed_music")
when "sound recording-nonmusical"
content_type = ContentType.find_by(name: "spoken_word")
when "moving image"
content_type = ContentType.find_by(name: "two_dimensional_moving_image")
when "software, multimedia"
content_type = ContentType.find_by(name: "other")
when "cartographic "
content_type = ContentType.find_by(name: "cartographic_image")
when "notated music"
content_type = ContentType.find_by(name: "notated_music")
when "still image"
content_type = ContentType.find_by(name: "still_image")
when "three dimensional object"
content_type = ContentType.find_by(name: "other")
when "mixed material"
content_type = ContentType.find_by(name: "other")
end
{ carrier_type: carrier_type, content_type: content_type }
end
end
end
class RecordNotFound < StandardError
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/user_reserve_stat_mailer.rb | app/mailers/user_reserve_stat_mailer.rb | class UserReserveStatMailer < ApplicationMailer
def completed(stat)
@library_group = LibraryGroup.site_config
@stat = stat
system_name = LibraryGroup.system_name(stat.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('user_reserve_stat_mailer.completed', locale: stat.user.profile.locale)}"
mail(from: from, to: stat.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/event_import_mailer.rb | app/mailers/event_import_mailer.rb | class EventImportMailer < ApplicationMailer
def completed(event_import_file)
@event_import_file = event_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(event_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('event_import_mailer.completed.subject')}: #{@event_import_file.id}"
mail(from: from, to: event_import_file.user.email, subject: subject)
end
def failed(event_import_file)
@event_import_file = event_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(event_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('event_import_mailer.failed.subject')}: #{@event_import_file.id}"
mail(from: from, to: event_import_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/agent_import_mailer.rb | app/mailers/agent_import_mailer.rb | class AgentImportMailer < ApplicationMailer
def completed(agent_import_file)
@agent_import_file = agent_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(agent_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('agent_import_mailer.completed.subject')}: #{@agent_import_file.id}"
mail(from: from, to: agent_import_file.user.email, subject: subject)
end
def failed(agent_import_file)
@agent_import_file = agent_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(agent_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('agent_import_mailer.failed.subject')}: #{@agent_import_file.id}"
mail(from: from, to: agent_import_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/checkout_mailer.rb | app/mailers/checkout_mailer.rb | class CheckoutMailer < ApplicationMailer
def due_date(checkout)
@library_group = LibraryGroup.site_config
@checkout = checkout
system_name = LibraryGroup.system_name(checkout.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('checkout_mailer.due_date')}"
mail(from: from, to: checkout.user.email, cc: from, subject: subject)
end
def overdue(checkout)
@library_group = LibraryGroup.site_config
@checkout = checkout
system_name = LibraryGroup.system_name(checkout.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('checkout_mailer.overdue')}"
mail(from: from, to: checkout.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/resource_import_mailer.rb | app/mailers/resource_import_mailer.rb | class ResourceImportMailer < ApplicationMailer
def completed(resource_import_file)
@resource_import_file = resource_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(resource_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('resource_import_mailer.completed.subject')}: #{@resource_import_file.id}"
mail(from: from, to: resource_import_file.user.email, subject: subject)
end
def failed(resource_import_file)
@resource_import_file = resource_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(resource_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('resource_import_mailer.failed.subject')}: #{@resource_import_file.id}"
mail(from: from, to: resource_import_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/application_mailer.rb | app/mailers/application_mailer.rb | class ApplicationMailer < ActionMailer::Base
default from: "from@example.com"
layout "mailer"
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/reserve_mailer.rb | app/mailers/reserve_mailer.rb | class ReserveMailer < ApplicationMailer
def accepted(reserve)
@library_group = LibraryGroup.site_config
@reserve = reserve
system_name = LibraryGroup.system_name(reserve.user.profile.locale)
from = "#{system_name}] <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('reserve_mailer.accepted')}"
mail(from: from, to: reserve.user.email, cc: from, subject: subject)
end
def canceled(reserve)
@library_group = LibraryGroup.site_config
@reserve = reserve
system_name = LibraryGroup.system_name(reserve.user.profile.locale)
from = "#{system_name}] <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('reserve_mailer.canceled')}"
mail(from: from, to: reserve.user.email, cc: from, subject: subject)
end
def expired(reserve)
@library_group = LibraryGroup.site_config
@reserve = reserve
system_name = LibraryGroup.system_name(reserve.user.profile.locale)
from = "#{system_name}] <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('reserve_mailer.expired')}"
mail(from: from, to: reserve.user.email, cc: from, subject: subject)
end
def retained(reserve)
@library_group = LibraryGroup.site_config
@reserve = reserve
system_name = LibraryGroup.system_name(reserve.user.profile.locale)
from = "#{system_name}] <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('reserve_mailer.retained')}"
mail(from: from, to: reserve.user.email, cc: from, subject: subject)
end
def postponed(reserve)
@library_group = LibraryGroup.site_config
@reserve = reserve
system_name = LibraryGroup.system_name(reserve.user.profile.locale)
from = "#{system_name}] <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('reserve_mailer.postponed')}"
mail(from: from, to: reserve.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/event_export_mailer.rb | app/mailers/event_export_mailer.rb | class EventExportMailer < ApplicationMailer
def completed(event_export_file)
@event_export_file = event_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(event_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('event_export_mailer.completed.subject')}: #{@event_export_file.id}"
mail(from: from, to: event_export_file.user.email, subject: subject)
end
def failed(event_export_file)
@event_export_file = event_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(event_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('event_export_mailer.failed.subject')}: #{@event_export_file.id}"
mail(from: from, to: event_export_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/manifestation_checkout_stat_mailer.rb | app/mailers/manifestation_checkout_stat_mailer.rb | class ManifestationCheckoutStatMailer < ApplicationMailer
def completed(stat)
@library_group = LibraryGroup.site_config
@stat = stat
system_name = LibraryGroup.system_name(stat.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('manifestation_checkout_stat_mailer.completed', locale: stat.user.profile.locale)}"
mail(from: from, to: stat.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/user_import_mailer.rb | app/mailers/user_import_mailer.rb | class UserImportMailer < ApplicationMailer
def completed(user_import_file)
@user_import_file = user_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('user_import_mailer.completed.subject')}: #{@user_import_file.id}"
mail(from: from, to: user_import_file.user.email, subject: subject)
end
def failed(user_import_file)
@user_import_file = user_import_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(user_import_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('user_import_mailer.failed.subject')}: #{@user_import_file.id}"
mail(from: from, to: user_import_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/notifier.rb | app/mailers/notifier.rb | class Notifier < ApplicationMailer
def message_notification(message_id)
message = Message.find(message_id)
from = "#{LibraryGroup.system_name(message.receiver.profile.locale)} <#{LibraryGroup.site_config.email}>"
if message.subject
subject = message.subject
else
subject = I18n.t("message.new_message_from_library", library: LibraryGroup.system_name(message.receiver.user.profile.locale))
end
if message.sender
@sender_name = message.sender.username
else
@sender_name = LibraryGroup.system_name(message.receiver.profile.locale)
end
@message = message
@locale = message.receiver.profile.locale
mail(from: from, to: message.receiver.email, subject: subject)
end
def manifestation_info(user_id, manifestation_id)
user = User.find(user_id)
manifestation = Manifestation.find(manifestation_id)
from = "#{LibraryGroup.system_name(user.profile.locale)} <#{LibraryGroup.site_config.email}>"
subject = "#{manifestation.original_title} : #{LibraryGroup.system_name(user.profile.locale)}"
@user = user
@items = Pundit.policy_scope!(user, manifestation.items)
@manifestation = manifestation
mail(from: from, to: user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/resource_export_mailer.rb | app/mailers/resource_export_mailer.rb | class ResourceExportMailer < ApplicationMailer
def completed(resource_export_file)
@resource_export_file = resource_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(resource_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('resource_export_mailer.completed.subject')}: #{@resource_export_file.id}"
mail(from: from, to: resource_export_file.user.email, subject: subject)
end
def failed(resource_export_file)
@resource_export_file = resource_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(resource_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('resource_export_mailer.failed.subject')}: #{@resource_export_file.id}"
mail(from: from, to: resource_export_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/user_checkout_stat_mailer.rb | app/mailers/user_checkout_stat_mailer.rb | class UserCheckoutStatMailer < ApplicationMailer
def completed(stat)
@library_group = LibraryGroup.site_config
@stat = stat
system_name = LibraryGroup.system_name(stat.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('user_checkout_stat_mailer.completed', locale: stat.user.profile.locale)}"
mail(from: from, to: stat.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/manifestation_reserve_stat_mailer.rb | app/mailers/manifestation_reserve_stat_mailer.rb | class ManifestationReserveStatMailer < ApplicationMailer
def completed(stat)
@library_group = LibraryGroup.site_config
@stat = stat
system_name = LibraryGroup.system_name(stat.user.profile.locale)
from = "#{system_name} <#{@library_group.email}>"
subject = "[#{system_name}] #{I18n.t('manifestation_reserve_stat_mailer.completed', locale: stat.user.profile.locale)}"
mail(from: from, to: stat.user.email, cc: from, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/mailers/user_export_mailer.rb | app/mailers/user_export_mailer.rb | class UserExportMailer < ApplicationMailer
def completed(user_export_file)
@user_export_file = user_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('user_export_mailer.completed.subject')}: #{@user_export_file.id}"
mail(from: from, to: user_export_file.user.email, subject: subject)
end
def failed(user_export_file)
@user_export_file = user_export_file
@library_group = LibraryGroup.site_config
from = "#{LibraryGroup.system_name(user_export_file.user.profile.locale)} <#{@library_group.email}>"
subject = "#{I18n.t('user_export_mailer.failed.subject')}: #{@user_export_file.id}"
mail(from: from, to: user_export_file.user.email, subject: subject)
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/channels/application_cable/channel.rb | app/channels/application_cable/channel.rb | module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/app/channels/application_cable/connection.rb | app/channels/application_cable/connection.rb | module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/seeds.rb | db/seeds.rb | username = 'enjuadmin'
email = 'admin@example.jp'
password = 'adminpassword'
# Don't edit the following lines!
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
#unless solr = Sunspot.commit rescue nil
# raise "Solr is not running."
#end
def new_profile
profile = Profile.new
profile.user_group = UserGroup.first
profile.library = Library.real.first
profile.locale = I18n.default_locale.to_s
profile
end
Rake::Task['enju_leaf:setup'].invoke
if User.count.zero?
system_user = User.new(
username: 'system',
email: 'root@library.example.jp',
role: Role.find_by(name: 'Administrator')
)
system_user.password = SecureRandom.urlsafe_base64(32)
profile = new_profile
profile.save!
system_user.profile = profile
system_user.save!
LibraryGroup.first.update!(
email: system_user.email,
url: ENV['ENJU_LEAF_BASE_URL']
)
UserGroup.order(created_at: :desc).first.update!(
number_of_day_to_notify_overdue: 7,
number_of_day_to_notify_due_date: 3
)
user = User.new(
username: username,
email: email,
role: Role.find_by(name: 'Administrator')
)
user.password = password
user.password_confirmation = password
profile = new_profile
profile.user_number = '0'
profile.save!
user.profile = profile
user.save!
puts 'Administrator account created.'
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/queue_schema.rb | db/queue_schema.rb | ActiveRecord::Schema[7.1].define(version: 1) do
create_table "solid_queue_blocked_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
t.integer "priority", default: 0, null: false
t.string "concurrency_key", null: false
t.datetime "expires_at", null: false
t.datetime "created_at", null: false
t.index [ "concurrency_key", "priority", "job_id" ], name: "index_solid_queue_blocked_executions_for_release"
t.index [ "expires_at", "concurrency_key" ], name: "index_solid_queue_blocked_executions_for_maintenance"
t.index [ "job_id" ], name: "index_solid_queue_blocked_executions_on_job_id", unique: true
end
create_table "solid_queue_claimed_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.bigint "process_id"
t.datetime "created_at", null: false
t.index [ "job_id" ], name: "index_solid_queue_claimed_executions_on_job_id", unique: true
t.index [ "process_id", "job_id" ], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id"
end
create_table "solid_queue_failed_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.text "error"
t.datetime "created_at", null: false
t.index [ "job_id" ], name: "index_solid_queue_failed_executions_on_job_id", unique: true
end
create_table "solid_queue_jobs", force: :cascade do |t|
t.string "queue_name", null: false
t.string "class_name", null: false
t.text "arguments"
t.integer "priority", default: 0, null: false
t.string "active_job_id"
t.datetime "scheduled_at"
t.datetime "finished_at"
t.string "concurrency_key"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index [ "active_job_id" ], name: "index_solid_queue_jobs_on_active_job_id"
t.index [ "class_name" ], name: "index_solid_queue_jobs_on_class_name"
t.index [ "finished_at" ], name: "index_solid_queue_jobs_on_finished_at"
t.index [ "queue_name", "finished_at" ], name: "index_solid_queue_jobs_for_filtering"
t.index [ "scheduled_at", "finished_at" ], name: "index_solid_queue_jobs_for_alerting"
end
create_table "solid_queue_pauses", force: :cascade do |t|
t.string "queue_name", null: false
t.datetime "created_at", null: false
t.index [ "queue_name" ], name: "index_solid_queue_pauses_on_queue_name", unique: true
end
create_table "solid_queue_processes", force: :cascade do |t|
t.string "kind", null: false
t.datetime "last_heartbeat_at", null: false
t.bigint "supervisor_id"
t.integer "pid", null: false
t.string "hostname"
t.text "metadata"
t.datetime "created_at", null: false
t.string "name", null: false
t.index [ "last_heartbeat_at" ], name: "index_solid_queue_processes_on_last_heartbeat_at"
t.index [ "name", "supervisor_id" ], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true
t.index [ "supervisor_id" ], name: "index_solid_queue_processes_on_supervisor_id"
end
create_table "solid_queue_ready_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
t.integer "priority", default: 0, null: false
t.datetime "created_at", null: false
t.index [ "job_id" ], name: "index_solid_queue_ready_executions_on_job_id", unique: true
t.index [ "priority", "job_id" ], name: "index_solid_queue_poll_all"
t.index [ "queue_name", "priority", "job_id" ], name: "index_solid_queue_poll_by_queue"
end
create_table "solid_queue_recurring_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "task_key", null: false
t.datetime "run_at", null: false
t.datetime "created_at", null: false
t.index [ "job_id" ], name: "index_solid_queue_recurring_executions_on_job_id", unique: true
t.index [ "task_key", "run_at" ], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true
end
create_table "solid_queue_recurring_tasks", force: :cascade do |t|
t.string "key", null: false
t.string "schedule", null: false
t.string "command", limit: 2048
t.string "class_name"
t.text "arguments"
t.string "queue_name"
t.integer "priority", default: 0
t.boolean "static", default: true, null: false
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index [ "key" ], name: "index_solid_queue_recurring_tasks_on_key", unique: true
t.index [ "static" ], name: "index_solid_queue_recurring_tasks_on_static"
end
create_table "solid_queue_scheduled_executions", force: :cascade do |t|
t.bigint "job_id", null: false
t.string "queue_name", null: false
t.integer "priority", default: 0, null: false
t.datetime "scheduled_at", null: false
t.datetime "created_at", null: false
t.index [ "job_id" ], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true
t.index [ "scheduled_at", "priority", "job_id" ], name: "index_solid_queue_dispatch_all"
end
create_table "solid_queue_semaphores", force: :cascade do |t|
t.string "key", null: false
t.integer "value", default: 1, null: false
t.datetime "expires_at", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index [ "expires_at" ], name: "index_solid_queue_semaphores_on_expires_at"
t.index [ "key", "value" ], name: "index_solid_queue_semaphores_on_key_and_value"
t.index [ "key" ], name: "index_solid_queue_semaphores_on_key", unique: true
end
add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/cache_schema.rb | db/cache_schema.rb | # frozen_string_literal: true
ActiveRecord::Schema[7.2].define(version: 1) do
create_table "solid_cache_entries", force: :cascade do |t|
t.binary "key", limit: 1024, null: false
t.binary "value", limit: 536870912, null: false
t.datetime "created_at", null: false
t.integer "key_hash", limit: 8, null: false
t.integer "byte_size", limit: 4, null: false
t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size"
t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size"
t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/schema.rb | db/schema.rb | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2025_07_27_021342) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "accepts", force: :cascade do |t|
t.bigint "basket_id"
t.bigint "item_id"
t.bigint "librarian_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["basket_id"], name: "index_accepts_on_basket_id"
t.index ["item_id"], name: "index_accepts_on_item_id", unique: true
t.index ["librarian_id"], name: "index_accepts_on_librarian_id"
end
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", precision: nil, null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", precision: nil, null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.bigint "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "agent_import_file_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}, null: false
t.integer "sort_key"
t.bigint "agent_import_file_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
t.index ["agent_import_file_id", "most_recent"], name: "index_agent_import_file_transitions_parent_most_recent", unique: true, where: "most_recent"
t.index ["agent_import_file_id"], name: "index_agent_import_file_transitions_on_agent_import_file_id"
t.index ["sort_key", "agent_import_file_id"], name: "index_agent_import_file_transitions_on_sort_key_and_file_id", unique: true
end
create_table "agent_import_files", force: :cascade do |t|
t.bigint "parent_id"
t.bigint "user_id", null: false
t.text "note"
t.datetime "executed_at", precision: nil
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "agent_import_fingerprint"
t.text "error_message"
t.string "edit_mode"
t.string "user_encoding"
t.index ["parent_id"], name: "index_agent_import_files_on_parent_id"
t.index ["user_id"], name: "index_agent_import_files_on_user_id"
end
create_table "agent_import_results", force: :cascade do |t|
t.bigint "agent_import_file_id"
t.bigint "agent_id"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "agent_merge_lists", force: :cascade do |t|
t.string "title"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "agent_merges", force: :cascade do |t|
t.bigint "agent_id", null: false
t.bigint "agent_merge_list_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["agent_id"], name: "index_agent_merges_on_agent_id"
t.index ["agent_merge_list_id"], name: "index_agent_merges_on_agent_merge_list_id"
end
create_table "agent_relationship_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_agent_relationship_types_on_lower_name", unique: true
end
create_table "agent_relationships", force: :cascade do |t|
t.bigint "parent_id"
t.bigint "child_id"
t.bigint "agent_relationship_type_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "position"
t.index ["child_id"], name: "index_agent_relationships_on_child_id"
t.index ["parent_id"], name: "index_agent_relationships_on_parent_id"
end
create_table "agent_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_agent_types_on_lower_name", unique: true
end
create_table "agents", force: :cascade do |t|
t.string "last_name"
t.string "middle_name"
t.string "first_name"
t.string "last_name_transcription"
t.string "middle_name_transcription"
t.string "first_name_transcription"
t.string "corporate_name"
t.string "corporate_name_transcription"
t.string "full_name"
t.text "full_name_transcription"
t.text "full_name_alternative"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "zip_code_1"
t.string "zip_code_2"
t.text "address_1"
t.text "address_2"
t.text "address_1_note"
t.text "address_2_note"
t.string "telephone_number_1"
t.string "telephone_number_2"
t.string "fax_number_1"
t.string "fax_number_2"
t.text "other_designation"
t.text "place"
t.string "postal_code"
t.text "street"
t.text "locality"
t.text "region"
t.datetime "date_of_birth", precision: nil
t.datetime "date_of_death", precision: nil
t.bigint "language_id", default: 1, null: false
t.bigint "country_id", default: 1, null: false
t.bigint "agent_type_id", default: 1, null: false
t.integer "lock_version", default: 0, null: false
t.text "note"
t.bigint "required_role_id", default: 1, null: false
t.integer "required_score", default: 0, null: false
t.text "email"
t.text "url"
t.text "full_name_alternative_transcription"
t.string "birth_date"
t.string "death_date"
t.string "agent_identifier"
t.bigint "profile_id"
t.index ["agent_identifier"], name: "index_agents_on_agent_identifier"
t.index ["country_id"], name: "index_agents_on_country_id"
t.index ["full_name"], name: "index_agents_on_full_name"
t.index ["language_id"], name: "index_agents_on_language_id"
t.index ["profile_id"], name: "index_agents_on_profile_id"
t.index ["required_role_id"], name: "index_agents_on_required_role_id"
end
create_table "baskets", force: :cascade do |t|
t.bigint "user_id"
t.text "note"
t.integer "lock_version", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_baskets_on_user_id"
end
create_table "bookmark_stat_has_manifestations", force: :cascade do |t|
t.bigint "bookmark_stat_id", null: false
t.bigint "manifestation_id", null: false
t.integer "bookmarks_count"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["bookmark_stat_id"], name: "index_bookmark_stat_has_manifestations_on_bookmark_stat_id"
t.index ["manifestation_id"], name: "index_bookmark_stat_has_manifestations_on_manifestation_id"
end
create_table "bookmark_stat_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}, null: false
t.integer "sort_key"
t.bigint "bookmark_stat_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
t.index ["bookmark_stat_id", "most_recent"], name: "index_bookmark_stat_transitions_parent_most_recent", unique: true, where: "most_recent"
t.index ["bookmark_stat_id"], name: "index_bookmark_stat_transitions_on_bookmark_stat_id"
t.index ["sort_key", "bookmark_stat_id"], name: "index_bookmark_stat_transitions_on_sort_key_and_stat_id", unique: true
end
create_table "bookmark_stats", force: :cascade do |t|
t.datetime "start_date", precision: nil
t.datetime "end_date", precision: nil
t.datetime "started_at", precision: nil
t.datetime "completed_at", precision: nil
t.text "note"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "bookmarks", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "manifestation_id"
t.text "title"
t.string "url"
t.text "note"
t.boolean "shared"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["manifestation_id"], name: "index_bookmarks_on_manifestation_id"
t.index ["url"], name: "index_bookmarks_on_url"
t.index ["user_id"], name: "index_bookmarks_on_user_id"
end
create_table "bookstores", force: :cascade do |t|
t.text "name", null: false
t.string "zip_code"
t.text "address"
t.text "note"
t.string "telephone_number"
t.string "fax_number"
t.string "url"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "budget_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_budget_types_on_lower_name", unique: true
end
create_table "carrier_type_has_checkout_types", force: :cascade do |t|
t.bigint "carrier_type_id", null: false
t.bigint "checkout_type_id", null: false
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["carrier_type_id", "checkout_type_id"], name: "index_carrier_type_has_checkout_types_on_carrier_type_id", unique: true
t.index ["checkout_type_id"], name: "index_carrier_type_has_checkout_types_on_checkout_type_id"
end
create_table "carrier_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_carrier_types_on_lower_name", unique: true
end
create_table "checked_items", force: :cascade do |t|
t.bigint "item_id", null: false
t.bigint "basket_id", null: false
t.bigint "librarian_id"
t.datetime "due_date", precision: nil, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "user_id"
t.index ["basket_id"], name: "index_checked_items_on_basket_id"
t.index ["item_id", "basket_id"], name: "index_checked_items_on_item_id_and_basket_id", unique: true
t.index ["librarian_id"], name: "index_checked_items_on_librarian_id"
t.index ["user_id"], name: "index_checked_items_on_user_id"
end
create_table "checkins", force: :cascade do |t|
t.bigint "item_id", null: false
t.bigint "librarian_id"
t.bigint "basket_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lock_version", default: 0, null: false
t.index ["basket_id"], name: "index_checkins_on_basket_id"
t.index ["item_id", "basket_id"], name: "index_checkins_on_item_id_and_basket_id", unique: true
t.index ["librarian_id"], name: "index_checkins_on_librarian_id"
end
create_table "checkout_stat_has_manifestations", force: :cascade do |t|
t.bigint "manifestation_checkout_stat_id", null: false
t.bigint "manifestation_id", null: false
t.integer "checkouts_count"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["manifestation_checkout_stat_id"], name: "index_checkout_stat_has_manifestations_on_checkout_stat_id"
t.index ["manifestation_id"], name: "index_checkout_stat_has_manifestations_on_manifestation_id"
end
create_table "checkout_stat_has_users", force: :cascade do |t|
t.bigint "user_checkout_stat_id", null: false
t.bigint "user_id", null: false
t.integer "checkouts_count", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_checkout_stat_id"], name: "index_checkout_stat_has_users_on_user_checkout_stat_id"
t.index ["user_id"], name: "index_checkout_stat_has_users_on_user_id"
end
create_table "checkout_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_checkout_types_on_lower_name", unique: true
end
create_table "checkouts", force: :cascade do |t|
t.bigint "user_id"
t.bigint "item_id", null: false
t.bigint "checkin_id"
t.bigint "librarian_id"
t.bigint "basket_id"
t.datetime "due_date", precision: nil
t.integer "checkout_renewal_count", default: 0, null: false
t.integer "lock_version", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "shelf_id"
t.bigint "library_id"
t.index ["basket_id"], name: "index_checkouts_on_basket_id"
t.index ["checkin_id"], name: "index_checkouts_on_checkin_id"
t.index ["item_id", "basket_id", "user_id"], name: "index_checkouts_on_item_id_and_basket_id_and_user_id", unique: true
t.index ["item_id"], name: "index_checkouts_on_item_id"
t.index ["librarian_id"], name: "index_checkouts_on_librarian_id"
t.index ["library_id"], name: "index_checkouts_on_library_id"
t.index ["shelf_id"], name: "index_checkouts_on_shelf_id"
t.index ["user_id"], name: "index_checkouts_on_user_id"
end
create_table "circulation_statuses", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_circulation_statuses_on_lower_name", unique: true
end
create_table "classification_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_classification_types_on_lower_name", unique: true
end
create_table "classifications", force: :cascade do |t|
t.bigint "parent_id"
t.string "category", null: false
t.text "note"
t.bigint "classification_type_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "lft"
t.integer "rgt"
t.bigint "manifestation_id"
t.string "url"
t.string "label"
t.index ["category"], name: "index_classifications_on_category"
t.index ["classification_type_id"], name: "index_classifications_on_classification_type_id"
t.index ["manifestation_id"], name: "index_classifications_on_manifestation_id"
t.index ["parent_id"], name: "index_classifications_on_parent_id"
end
create_table "colors", force: :cascade do |t|
t.bigint "library_group_id"
t.string "property"
t.string "code"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["library_group_id"], name: "index_colors_on_library_group_id"
end
create_table "content_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_content_types_on_lower_name", unique: true
end
create_table "countries", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.string "alpha_2"
t.string "alpha_3"
t.string "numeric_3"
t.text "note"
t.integer "position"
t.index "lower((name)::text)", name: "index_countries_on_lower_name", unique: true
t.index ["alpha_2"], name: "index_countries_on_alpha_2"
t.index ["alpha_3"], name: "index_countries_on_alpha_3"
t.index ["numeric_3"], name: "index_countries_on_numeric_3"
end
create_table "create_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_create_types_on_lower_name", unique: true
end
create_table "creates", force: :cascade do |t|
t.bigint "agent_id", null: false
t.bigint "work_id", null: false
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "create_type_id"
t.index ["agent_id"], name: "index_creates_on_agent_id"
t.index ["work_id", "agent_id"], name: "index_creates_on_work_id_and_agent_id", unique: true
end
create_table "demands", force: :cascade do |t|
t.bigint "user_id", null: false
t.bigint "item_id"
t.bigint "message_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["item_id"], name: "index_demands_on_item_id"
t.index ["message_id"], name: "index_demands_on_message_id"
t.index ["user_id"], name: "index_demands_on_user_id"
end
create_table "doi_records", force: :cascade do |t|
t.string "body", null: false
t.bigint "manifestation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((body)::text), manifestation_id", name: "index_doi_records_on_lower_body_manifestation_id", unique: true
t.index ["manifestation_id"], name: "index_doi_records_on_manifestation_id"
end
create_table "donates", force: :cascade do |t|
t.bigint "agent_id", null: false
t.bigint "item_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["agent_id"], name: "index_donates_on_agent_id"
t.index ["item_id"], name: "index_donates_on_item_id"
end
create_table "event_categories", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "event_export_file_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}, null: false
t.integer "sort_key"
t.bigint "event_export_file_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
t.index ["event_export_file_id", "most_recent"], name: "index_event_export_file_transitions_parent_most_recent", unique: true, where: "most_recent"
t.index ["event_export_file_id"], name: "index_event_export_file_transitions_on_file_id"
t.index ["sort_key", "event_export_file_id"], name: "index_event_export_file_transitions_on_sort_key_and_file_id", unique: true
end
create_table "event_export_files", force: :cascade do |t|
t.bigint "user_id", null: false
t.datetime "executed_at", precision: nil
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_event_export_files_on_user_id"
end
create_table "event_import_file_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}, null: false
t.integer "sort_key"
t.bigint "event_import_file_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
t.index ["event_import_file_id", "most_recent"], name: "index_event_import_file_transitions_parent_most_recent", unique: true, where: "most_recent"
t.index ["event_import_file_id"], name: "index_event_import_file_transitions_on_event_import_file_id"
t.index ["sort_key", "event_import_file_id"], name: "index_event_import_file_transitions_on_sort_key_and_file_id", unique: true
end
create_table "event_import_files", force: :cascade do |t|
t.bigint "parent_id"
t.bigint "user_id", null: false
t.text "note"
t.datetime "executed_at", precision: nil
t.string "edit_mode"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "event_import_fingerprint"
t.text "error_message"
t.string "user_encoding"
t.bigint "default_library_id"
t.bigint "default_event_category_id"
t.index ["parent_id"], name: "index_event_import_files_on_parent_id"
t.index ["user_id"], name: "index_event_import_files_on_user_id"
end
create_table "event_import_results", force: :cascade do |t|
t.bigint "event_import_file_id"
t.bigint "event_id"
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "events", force: :cascade do |t|
t.bigint "library_id", null: false
t.bigint "event_category_id", null: false
t.string "name", null: false
t.text "note"
t.datetime "start_at", precision: nil
t.datetime "end_at", precision: nil
t.boolean "all_day", default: false, null: false
t.text "display_name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "place_id"
t.index ["event_category_id"], name: "index_events_on_event_category_id"
t.index ["library_id"], name: "index_events_on_library_id"
t.index ["place_id"], name: "index_events_on_place_id"
end
create_table "form_of_works", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_form_of_works_on_lower_name", unique: true
end
create_table "frequencies", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_frequencies_on_lower_name", unique: true
end
create_table "identifier_types", force: :cascade do |t|
t.string "name", null: false
t.text "display_name"
t.text "note"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_identifier_types_on_lower_name", unique: true
end
create_table "identifiers", force: :cascade do |t|
t.string "body", null: false
t.bigint "identifier_type_id", null: false
t.bigint "manifestation_id"
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["body", "identifier_type_id"], name: "index_identifiers_on_body_and_identifier_type_id"
t.index ["manifestation_id"], name: "index_identifiers_on_manifestation_id"
end
create_table "identities", force: :cascade do |t|
t.string "name", null: false
t.string "email"
t.string "password_digest"
t.bigint "profile_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "provider"
t.index ["email"], name: "index_identities_on_email"
t.index ["name"], name: "index_identities_on_name"
t.index ["profile_id"], name: "index_identities_on_profile_id"
end
create_table "import_request_transitions", force: :cascade do |t|
t.string "to_state"
t.jsonb "metadata", default: {}, null: false
t.integer "sort_key"
t.bigint "import_request_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "most_recent", null: false
t.index ["import_request_id", "most_recent"], name: "index_import_request_transitions_parent_most_recent", unique: true, where: "most_recent"
t.index ["import_request_id"], name: "index_import_request_transitions_on_import_request_id"
t.index ["sort_key", "import_request_id"], name: "index_import_request_transitions_on_sort_key_and_request_id", unique: true
end
create_table "import_requests", force: :cascade do |t|
t.string "isbn"
t.bigint "manifestation_id"
t.bigint "user_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["isbn"], name: "index_import_requests_on_isbn"
t.index ["manifestation_id"], name: "index_import_requests_on_manifestation_id"
t.index ["user_id"], name: "index_import_requests_on_user_id"
end
create_table "inventories", force: :cascade do |t|
t.bigint "item_id"
t.bigint "inventory_file_id"
t.text "note"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "item_identifier"
t.string "current_shelf_name"
t.index ["current_shelf_name"], name: "index_inventories_on_current_shelf_name"
t.index ["inventory_file_id"], name: "index_inventories_on_inventory_file_id"
t.index ["item_id"], name: "index_inventories_on_item_id"
t.index ["item_identifier"], name: "index_inventories_on_item_identifier"
end
create_table "inventory_files", force: :cascade do |t|
t.bigint "user_id", null: false
t.text "note"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "inventory_fingerprint"
t.bigint "shelf_id"
t.index ["shelf_id"], name: "index_inventory_files_on_shelf_id"
t.index ["user_id"], name: "index_inventory_files_on_user_id"
end
create_table "isbn_record_and_manifestations", comment: "書誌とISBNの関係", force: :cascade do |t|
t.bigint "isbn_record_id", null: false
t.bigint "manifestation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["isbn_record_id"], name: "index_isbn_record_and_manifestations_on_isbn_record_id"
t.index ["manifestation_id", "isbn_record_id"], name: "index_isbn_record_and_manifestations_on_manifestation_id", unique: true
end
create_table "isbn_records", comment: "ISBN", force: :cascade do |t|
t.string "body", null: false, comment: "ISBN"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["body"], name: "index_isbn_records_on_body"
end
create_table "issn_record_and_manifestations", comment: "書誌とISSNの関係", force: :cascade do |t|
t.bigint "issn_record_id", null: false
t.bigint "manifestation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["issn_record_id"], name: "index_issn_record_and_manifestations_on_issn_record_id"
t.index ["manifestation_id", "issn_record_id"], name: "index_issn_record_and_manifestations_on_manifestation_id", unique: true
end
create_table "issn_records", comment: "ISSN", force: :cascade do |t|
t.string "body", null: false, comment: "ISSN"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["body"], name: "index_issn_records_on_body", unique: true
end
create_table "item_custom_properties", force: :cascade do |t|
t.string "name", null: false, comment: "ラベル名"
t.text "display_name", null: false, comment: "表示名"
t.text "note", comment: "備考"
t.integer "position", default: 1, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index "lower((name)::text)", name: "index_item_custom_properties_on_lower_name", unique: true
end
create_table "item_custom_values", force: :cascade do |t|
t.bigint "item_custom_property_id", null: false
t.bigint "item_id", null: false
t.text "value"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["item_custom_property_id", "item_id"], name: "index_item_custom_values_on_custom_item_property_and_item_id", unique: true
t.index ["item_custom_property_id"], name: "index_item_custom_values_on_custom_property_id"
t.index ["item_id"], name: "index_item_custom_values_on_item_id"
end
create_table "item_has_use_restrictions", force: :cascade do |t|
t.bigint "item_id", null: false
t.bigint "use_restriction_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["item_id", "use_restriction_id"], name: "index_item_has_use_restrictions_on_item_and_use_restriction", unique: true
t.index ["use_restriction_id"], name: "index_item_has_use_restrictions_on_use_restriction_id"
end
create_table "items", force: :cascade do |t|
t.string "call_number"
t.string "item_identifier"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "shelf_id", default: 1, null: false
t.boolean "include_supplements", default: false, null: false
t.text "note"
t.string "url"
t.integer "price"
t.integer "lock_version", default: 0, null: false
t.bigint "required_role_id", default: 1, null: false
t.integer "required_score", default: 0, null: false
t.datetime "acquired_at", precision: nil
t.bigint "bookstore_id"
t.bigint "budget_type_id"
t.bigint "circulation_status_id", default: 5, null: false
t.bigint "checkout_type_id", default: 1, null: false
t.string "binding_item_identifier"
t.string "binding_call_number"
t.datetime "binded_at", precision: nil
t.bigint "manifestation_id", null: false
t.text "memo"
t.date "missing_since"
t.index ["binding_item_identifier"], name: "index_items_on_binding_item_identifier"
t.index ["bookstore_id"], name: "index_items_on_bookstore_id"
t.index ["checkout_type_id"], name: "index_items_on_checkout_type_id"
t.index ["circulation_status_id"], name: "index_items_on_circulation_status_id"
t.index ["item_identifier"], name: "index_items_on_item_identifier", unique: true, where: "(((item_identifier)::text <> ''::text) AND (item_identifier IS NOT NULL))"
t.index ["manifestation_id"], name: "index_items_on_manifestation_id"
t.index ["required_role_id"], name: "index_items_on_required_role_id"
t.index ["shelf_id"], name: "index_items_on_shelf_id"
end
create_table "jpno_records", force: :cascade do |t|
t.string "body", null: false
t.bigint "manifestation_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["body"], name: "index_jpno_records_on_body", unique: true
t.index ["manifestation_id"], name: "index_jpno_records_on_manifestation_id"
end
create_table "languages", force: :cascade do |t|
t.string "name", null: false
t.string "native_name"
t.text "display_name"
t.string "iso_639_1"
t.string "iso_639_2"
t.string "iso_639_3"
t.text "note"
t.integer "position"
t.index "lower((name)::text)", name: "index_languages_on_lower_name", unique: true
t.index ["iso_639_1"], name: "index_languages_on_iso_639_1"
t.index ["iso_639_2"], name: "index_languages_on_iso_639_2"
t.index ["iso_639_3"], name: "index_languages_on_iso_639_3"
end
create_table "lccn_records", force: :cascade do |t|
t.string "body", null: false
t.bigint "manifestation_id", null: false
t.datetime "created_at", null: false
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | true |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/cable_schema.rb | db/cable_schema.rb | ActiveRecord::Schema[7.1].define(version: 1) do
create_table "solid_cable_messages", force: :cascade do |t|
t.binary "channel", limit: 1024, null: false
t.binary "payload", limit: 536870912, null: false
t.datetime "created_at", null: false
t.integer "channel_hash", limit: 8, null: false
t.index ["channel"], name: "index_solid_cable_messages_on_channel"
t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash"
t.index ["created_at"], name: "index_solid_cable_messages_on_created_at"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20180709023037_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb | db/migrate/20180709023037_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb | # This migration comes from acts_as_taggable_on_engine (originally 3)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
else
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
end
AddTaggingsCounterCacheToTags.class_eval do
def up
add_column :tags, :taggings_count, :integer, default: 0, if_not_exists: true
ActsAsTaggableOn::Tag.reset_column_information
ActsAsTaggableOn::Tag.find_each do |tag|
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
end
end
def down
remove_column :tags, :taggings_count
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20081031033632_create_news_feeds.rb | db/migrate/20081031033632_create_news_feeds.rb | class CreateNewsFeeds < ActiveRecord::Migration[4.2]
def up
create_table :news_feeds, if_not_exists: true do |t|
t.integer :library_group_id, default: 1, null: false
t.string :title
t.string :url
t.text :body
t.integer :position
t.timestamps
end
end
def down
drop_table :news_feeds
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb | db/migrate/20081216190517_create_reserve_stat_has_manifestations.rb | class CreateReserveStatHasManifestations < ActiveRecord::Migration[4.2]
def up
create_table :reserve_stat_has_manifestations do |t|
t.references :manifestation_reserve_stat, index: false, null: false
t.references :manifestation, index: false, foreign_key: true, null: false
t.integer :reserves_count
t.timestamps
end
add_index :reserve_stat_has_manifestations, :manifestation_reserve_stat_id, name: 'index_reserve_stat_has_manifestations_on_m_reserve_stat_id'
add_index :reserve_stat_has_manifestations, :manifestation_id
end
def down
drop_table :reserve_stat_has_manifestations
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20160506144040_create_isbn_records.rb | db/migrate/20160506144040_create_isbn_records.rb | class CreateIsbnRecords < ActiveRecord::Migration[6.1]
def change
create_table :isbn_records, comment: 'ISBN' do |t|
t.string :body, null: false, comment: 'ISBN'
t.timestamps
end
add_index :isbn_records, :body
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20151126005552_add_provider_to_identity.rb | db/migrate/20151126005552_add_provider_to_identity.rb | class AddProviderToIdentity < ActiveRecord::Migration[4.2]
def change
add_column :identities, :provider, :string
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/005_create_manifestations.rb | db/migrate/005_create_manifestations.rb | class CreateManifestations < ActiveRecord::Migration[4.2]
def change
create_table :manifestations do |t|
t.text :original_title, null: false
t.text :title_alternative
t.text :title_transcription
t.string :classification_number
t.string :manifestation_identifier
t.datetime :date_of_publication
t.datetime :copyright_date
t.timestamps
t.datetime :deleted_at
t.string :access_address
t.integer :language_id, default: 1, null: false
t.integer :carrier_type_id, default: 1, null: false
t.integer :start_page
t.integer :end_page
t.integer :height
t.integer :width
t.integer :depth
t.integer :price # TODO: 通貨単位
t.text :fulltext
t.string :volume_number_string
t.string :issue_number_string
t.string :serial_number_string
t.integer :edition
t.text :note
t.boolean :repository_content, default: false, null: false
t.integer :lock_version, default: 0, null: false
t.integer :required_role_id, default: 1, null: false
t.integer :required_score, default: 0, null: false
t.integer :frequency_id, default: 1, null: false
t.boolean :subscription_master, default: false, null: false
end
# add_index :manifestations, :carrier_type_id
# add_index :manifestations, :required_role_id
add_index :manifestations, :access_address
# add_index :manifestations, :frequency_id
add_index :manifestations, :manifestation_identifier
add_index :manifestations, :updated_at
add_index :manifestations, :date_of_publication
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/029_create_subjects.rb | db/migrate/029_create_subjects.rb | class CreateSubjects < ActiveRecord::Migration[4.2]
def up
create_table :subjects do |t|
t.references :parent, index: true
t.integer :use_term_id
t.string :term
t.text :term_transcription
t.references :subject_type, index: true, null: false
t.text :scope_note
t.text :note
t.references :required_role, index: true, default: 1, null: false
t.integer :lock_version, default: 0, null: false
t.datetime :created_at
t.datetime :updated_at
t.datetime :deleted_at
end
add_index :subjects, :term
add_index :subjects, :use_term_id
end
def down
drop_table :subjects
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20141115051741_remove_ncid_from_manifestations.rb | db/migrate/20141115051741_remove_ncid_from_manifestations.rb | class RemoveNcidFromManifestations < ActiveRecord::Migration[4.2]
def up
remove_column :manifestations, :ncid
end
def down
add_column :manifestations, :ncid
add_index :manifestations, :ncid
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20100606073747_create_agent_relationships.rb | db/migrate/20100606073747_create_agent_relationships.rb | class CreateAgentRelationships < ActiveRecord::Migration[4.2]
def change
create_table :agent_relationships do |t|
t.integer :parent_id
t.integer :child_id
t.integer :agent_relationship_type_id
t.timestamps
end
add_index :agent_relationships, :parent_id
add_index :agent_relationships, :child_id
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20140823094847_add_dimensions_to_manifestation.rb | db/migrate/20140823094847_add_dimensions_to_manifestation.rb | class AddDimensionsToManifestation < ActiveRecord::Migration[4.2]
def change
add_column :manifestations, :dimensions, :text
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20191224083828_add_item_identifier_to_inventory.rb | db/migrate/20191224083828_add_item_identifier_to_inventory.rb | class AddItemIdentifierToInventory < ActiveRecord::Migration[5.2]
def up
add_column :inventories, :item_identifier, :string, if_not_exists: true
add_index :inventories, :item_identifier
end
def down
remove_column :inventories, :item_identifier
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20250726132106_remove_old_solid_queue_tables.rb | db/migrate/20250726132106_remove_old_solid_queue_tables.rb | class RemoveOldSolidQueueTables < ActiveRecord::Migration[7.1]
def change
drop_table :solid_queue_blocked_executions, if_exists: true
drop_table :solid_queue_claimed_executions, if_exists: true
drop_table :solid_queue_failed_executions, if_exists: true
drop_table :solid_queue_scheduled_executions, if_exists: true
drop_table :solid_queue_ready_executions, if_exists: true
drop_table :solid_queue_recurring_executions, if_exists: true
drop_table :solid_queue_recurring_tasks, if_exists: true
drop_table :solid_queue_jobs, if_exists: true
drop_table :solid_queue_pauses, if_exists: true
drop_table :solid_queue_processes, if_exists: true
drop_table :solid_queue_semaphores, if_exists: true
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb | db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb | class AddMostRecentToUserImportFileTransitions < ActiveRecord::Migration[4.2]
def up
add_column :user_import_file_transitions, :most_recent, :boolean, null: true
end
def down
remove_column :user_import_file_transitions, :most_recent
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20191216131755_add_email_to_library_group.rb | db/migrate/20191216131755_add_email_to_library_group.rb | class AddEmailToLibraryGroup < ActiveRecord::Migration[6.1]
def change
add_column :library_groups, :email, :string
add_index :library_groups, :email
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20100925074559_create_agent_import_results.rb | db/migrate/20100925074559_create_agent_import_results.rb | class CreateAgentImportResults < ActiveRecord::Migration[4.2]
def change
create_table :agent_import_results do |t|
t.integer :agent_import_file_id
t.integer :agent_id
t.text :body
t.timestamps
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb | db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb | class AddMostRecentToAgentImportFileTransitions < ActiveRecord::Migration[4.2]
def up
add_column :agent_import_file_transitions, :most_recent, :boolean, null: true
end
def down
remove_column :agent_import_file_transitions, :most_recent
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20171126072934_create_ndla_records.rb | db/migrate/20171126072934_create_ndla_records.rb | class CreateNdlaRecords < ActiveRecord::Migration[5.2]
def up
create_table :ndla_records, if_not_exists: true do |t|
t.references :agent, foreign_key: true
t.string :body, null: false, index: {unique: true}
t.timestamps
end
end
def down
drop_table :ndla_records
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb | db/migrate/20100321235924_add_series_statement_identifier_to_series_statement.rb | class AddSeriesStatementIdentifierToSeriesStatement < ActiveRecord::Migration[4.2]
def up
add_column :series_statements, :series_statement_identifier, :string
add_index :series_statements, :series_statement_identifier
end
def down
remove_column :series_statements, :series_statement_identifier
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20160813191820_add_screenshot_generator_to_library_group.rb | db/migrate/20160813191820_add_screenshot_generator_to_library_group.rb | class AddScreenshotGeneratorToLibraryGroup < ActiveRecord::Migration[4.2]
def change
add_column :library_groups, :screenshot_generator, :string
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20081028083142_create_agent_import_files.rb | db/migrate/20081028083142_create_agent_import_files.rb | class CreateAgentImportFiles < ActiveRecord::Migration[4.2]
def change
create_table :agent_import_files do |t|
t.integer :parent_id
t.string :content_type
t.integer :size
t.integer :user_id
t.text :note
t.datetime :executed_at
t.string :agent_import_file_name
t.string :agent_import_content_type
t.integer :agent_import_file_size
t.datetime :agent_import_updated_at
t.timestamps
end
add_index :agent_import_files, :parent_id
add_index :agent_import_files, :user_id
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20191224091957_add_current_shelf_name_to_inventory.rb | db/migrate/20191224091957_add_current_shelf_name_to_inventory.rb | class AddCurrentShelfNameToInventory < ActiveRecord::Migration[5.2]
def up
add_column :inventories, :current_shelf_name, :string, if_not_exists: true
add_index :inventories, :current_shelf_name, if_not_exists: true
end
def down
remove_column :inventories, :current_shelf_name
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20081006090811_create_subscriptions.rb | db/migrate/20081006090811_create_subscriptions.rb | class CreateSubscriptions < ActiveRecord::Migration[4.2]
def change
create_table :subscriptions do |t|
t.text :title, null: false
t.text :note
t.references :user, index: true
t.references :order_list, index: true
t.datetime :deleted_at
t.integer :subscribes_count, default: 0, null: false
t.timestamps
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20120415060342_rename_event_import_file_imported_at_to_executed_at.rb | db/migrate/20120415060342_rename_event_import_file_imported_at_to_executed_at.rb | class RenameEventImportFileImportedAtToExecutedAt < ActiveRecord::Migration[4.2]
def up
rename_column :event_import_files, :imported_at, :executed_at
end
def down
rename_column :event_import_files, :executed_at, :impored_at
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20231027175439_add_unique_index_to_libraries_on_name.rb | db/migrate/20231027175439_add_unique_index_to_libraries_on_name.rb | class AddUniqueIndexToLibrariesOnName < ActiveRecord::Migration[6.1]
def change
add_index :libraries, :name, unique: true
add_index :libraries, :isil, unique: true, where: "isil != '' AND isil IS NOT NULL"
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb | db/migrate/20110627122938_add_number_of_day_to_notify_overdue_to_user_group.rb | class AddNumberOfDayToNotifyOverdueToUserGroup < ActiveRecord::Migration[4.2]
def up
add_column :user_groups, :number_of_day_to_notify_overdue, :integer, default: 0, null: false
add_column :user_groups, :number_of_day_to_notify_due_date, :integer, default: 0, null: false
add_column :user_groups, :number_of_time_to_notify_overdue, :integer, default: 0, null: false
end
def down
remove_column :user_groups, :number_of_time_to_notify_overdue
remove_column :user_groups, :number_of_day_to_notify_due_date
remove_column :user_groups, :number_of_day_to_notify_overdue
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20221112074731_add_index_to_libraries_on_name.rb | db/migrate/20221112074731_add_index_to_libraries_on_name.rb | class AddIndexToLibrariesOnName < ActiveRecord::Migration[6.1]
def change
[
:budget_types,
:create_types,
:events,
:identifier_types,
:identities,
:produce_types,
:realize_types,
:tags,
:user_groups
].each do |table|
change_column_null table, :name, false
end
[
:libraries,
:checkout_types,
:countries,
:item_custom_properties,
:languages,
:manifestation_custom_properties,
:nii_types,
].each do |table|
remove_index table, :name, if_exists: true
end
[
:libraries,
:roles,
:agent_relationship_types,
:agent_types,
:budget_types,
:carrier_types,
:checkout_types,
:circulation_statuses,
:classification_types,
:content_types,
:countries,
:create_types,
:form_of_works,
:frequencies,
:identifier_types,
:shelves,
:item_custom_properties,
:languages,
:library_groups,
:licenses,
:manifestation_custom_properties,
:manifestation_relationship_types,
:medium_of_performances,
:nii_types,
:produce_types,
:realize_types,
:request_status_types,
:request_types,
:subject_heading_types,
:subject_types,
:use_restrictions,
:user_groups
].each do |table|
add_index table, 'lower(name)', unique: true
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb | db/migrate/20140628072217_add_user_encoding_to_user_import_file.rb | class AddUserEncodingToUserImportFile < ActiveRecord::Migration[4.2]
def change
add_column :user_import_files, :user_encoding, :string
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20091214131723_create_series_statements.rb | db/migrate/20091214131723_create_series_statements.rb | class CreateSeriesStatements < ActiveRecord::Migration[4.2]
def change
create_table :series_statements do |t|
t.text :title
t.text :numbering
t.text :title_subseries
t.text :numbering_subseries
t.integer :position
t.timestamps
end
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb | db/migrate/20130509185724_add_statement_of_responsibility_to_manifestation.rb | class AddStatementOfResponsibilityToManifestation < ActiveRecord::Migration[4.2]
def change
add_column :manifestations, :statement_of_responsibility, :text
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20111129044509_add_pickup_location_to_reserve.rb | db/migrate/20111129044509_add_pickup_location_to_reserve.rb | class AddPickupLocationToReserve < ActiveRecord::Migration[4.2]
def change
add_column :reserves, :pickup_location_id, :integer
add_index :reserves, :pickup_location_id
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
next-l/enju_leaf | https://github.com/next-l/enju_leaf/blob/cd3cff6dcc8e67909e1cd0a12c38700b45af6a42/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb | db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb | class AddForeignKeyOnManifestationIdToReserve < ActiveRecord::Migration[4.2]
def change
add_foreign_key :reserves, :manifestations
end
end
| ruby | MIT | cd3cff6dcc8e67909e1cd0a12c38700b45af6a42 | 2026-01-04T17:52:15.550406Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.