Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/ht_downloads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class HTDownloadsController < ApplicationController
"rights_date_used" => :ht_hathifile_rights_date_used_eq,
"title" => :ht_hathifile_title_i_cont,
"pages" => :pages_eq,
"full_download" => :full_download_eq
"full_download" => :full_download_eq,
"seq" => :seq_eq
Copy link
Collaborator Author

@moseshll moseshll Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if ransack needs to even be aware of seq, it won't get used since there's no need to expose it in the UI as a search term.

}

# Translation table from params[:sortName] to a form Ransack can understand.
Expand All @@ -61,7 +62,8 @@ class HTDownloadsController < ApplicationController
"rights_date_used" => :ht_hathifile_rights_date_used,
"title" => :ht_hathifile_title,
"pages" => :pages,
"full_download" => :full_download
"full_download" => :full_download,
"seq" => :seq
}

def index
Expand Down
4 changes: 3 additions & 1 deletion app/lib/otis/log_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ def create_report(entry)
yyyymm: datetime.strftime("%Y%m"),
datetime: datetime,
htid: entry["id"],
is_partial: entry["is_partial"],
is_partial: entry["is_partial"] || 0,
# full_download: entry["is_partial"] ? 0 : 1,
# seq: entry["seq"],
email: translate_remote_user(entry["remote_user_processed"]),
inst_code: entry["inst_code"],
role: entry["role"],
Expand Down
2 changes: 1 addition & 1 deletion app/models/ht_download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class HTDownload < ApplicationRecord
scope :for_role, ->(role) { where(role: role) }

def self.ransackable_attributes(auth_object = nil)
["role", "datetime", "email", "htid", "id", "in_copyright", "inst_code", "sha", "yyyy", "yyyymm", "full_download", "pages"]
["role", "datetime", "email", "htid", "id", "in_copyright", "inst_code", "sha", "yyyy", "yyyymm", "full_download", "pages", "seq"]
end

def self.ransackable_associations(auth_object = nil)
Expand Down
4 changes: 3 additions & 1 deletion app/presenters/ht_download_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class HTDownloadPresenter < ApplicationPresenter
rights_date_used
full_download
pages
seq
].freeze

# Type of filter control to specify for a given column.
Expand All @@ -38,7 +39,8 @@ class HTDownloadPresenter < ApplicationPresenter
author: :input,
rights_date_used: :select,
full_download: :select,
pages: :select
pages: :select,
seq: :input
}.freeze

# Used below to create accessor methods for the relevant hathifiles.hf fields.
Expand Down
3 changes: 2 additions & 1 deletion app/views/ht_downloads/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
<th data-field="<%= field %>"
class="<%= th_class %>"
data-filter-control="<%= control %>"

data-force-export="true"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only interesting bit.

data-visible="<%= field != :seq ? "true" : "false" %>"
<% if filter_data %>
<%= "data-filter-data='#{filter_data}'".html_safe %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ en:
rights_code: Rights Code
rights_date_used: Rights Date
role: Role
seq: Page Sequence
title: Title
ht_institution:
allowed_affiliations: Affiliations
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ ja:
rights_code: 著作権コード
rights_date_used: 著作権の日付
role: 役割
seq: ページシーケンス
title: タイトル
ht_institution:
allowed_affiliations: 所属
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
t.binary :sha
t.string :role
t.integer :pages
t.string :seq
end

create_table "hathifiles.hf", id: false, if_not_exists: true do |t|
Expand Down
18 changes: 16 additions & 2 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,30 @@ def create_ht_registration

def create_download
datetime = Faker::Time.backward
# FIXME: is it correct to put nil?
# new `full_download` column should be NOT NULL
# Sorting table by is_partial is a problem when nil is allowed.
is_partial = [nil, false, true].sample

pages = nil
seq = nil
if is_partial
seq = [].tap do |acc|
Faker::Number.within(range: 1..20).times do |_i|
acc << Faker::Number.within(range: 1..100)
end
end.sort.uniq
pages = seq.count
seq = seq.join(",")
Copy link
Collaborator Author

@moseshll moseshll Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was happy with this little block of code to make a reasonable seq value. You'll never see it except in the exports.

end
rep = HTDownload.create(
in_copyright: [false, true].sample,
yyyy: datetime.year,
yyyymm: datetime.strftime("%Y%m"),
datetime: datetime,
htid: UNIQUE_HTIDS.keys.sample,
is_partial: is_partial,
pages: is_partial ? rand(100) : nil,
pages: pages,
seq: seq,
role: %w[ssdproxy resource_sharing].sample,
# FIXME: how about we make sure the email and institution code match?
email: UNIQUE_EMAILS.keys.sample,
Expand Down