Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove existing SubGuide belong_to association with GuideCard #84

Merged
merged 3 commits into from
Jun 5, 2023
Merged
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
1 change: 0 additions & 1 deletion app/models/sub_guide_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
# SubGuideCard class which each GuideCard belongs to
# Line 6 is a validation. The validation states that in order for a sub_guide to save it needs an associated guide_card
class SubGuideCard < ApplicationRecord
belongs_to :guide_card
end
9 changes: 4 additions & 5 deletions app/services/sub_guide_loading_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,22 @@ def initialize(csv_location: nil)
@csv_location = csv_location || Rails.root.join('data', 'dbo-subguides', 'dbo.Subguides.17917.csv')
end

def import(parent_guide:)
def import
sub_guide_card_data = CSV.parse(File.read(csv_location), headers: true)
sub_guide_card_data.each do |card|
import_sub_guide_card(card:, parent_guide:)
sub_guide_card_data.each do |entry|
import_sub_guide_card(entry)
end
end

private

def import_sub_guide_card(card:, parent_guide:)
def import_sub_guide_card(card)
sgc = SubGuideCard.new
sgc.id = card[0]
sgc.heading = card[1]
sgc.sortid = card[2]
sgc.parentid = card[3]
sgc.path = card[4]
sgc.guide_card = parent_guide
sgc.save
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# db migration for revert of belong_to association with GuideCard
class RemoveGuideCardFromSubGuideCards < ActiveRecord::Migration[7.0]
def change
remove_column :sub_guide_cards, :guide_card_id, :bigint
end
end
4 changes: 1 addition & 3 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions docs/image-processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Image Processing

ssh into systems@imagecat2.princeton.edu

`ssh systems@imagecat2.princeton.edu`

Obtain the 'Image Catalog' password for this server in [LastPass](https://www.lastpass.com/)

Once you are have ssh into the shell, navigate to the imagecat sub-directory

`cd /var/www/html/imagecat`

The images are located on the disk directories (numbered 1-14).

We want to extract ONLY the original .tiff images and import these to an AmazonS3 bucket.

They will be extracted to a local drive, where then the images will be moved to the S3 bucket. The images are currently housed on a local machine in the following path:

`cp *.tiff ../../../output/disk14/0001/A1002`

The PUL-iiif server will allow the user to render the images and interact with them as needed.
2 changes: 0 additions & 2 deletions spec/models/sub_guide_card_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
sub_guide_card.sortid = '50350.5'
sub_guide_card.parentid = '50345.5'
sub_guide_card.path = '9/0091/A3067'
sub_guide_card.guide_card = GuideCard.create
sub_guide_card.save
expect(sub_guide_card.id).to eq 2
expect(sub_guide_card.heading).to eq 'Afdeling natuurkunde'
expect(sub_guide_card.sortid).to eq '50350.5'
expect(sub_guide_card.parentid).to eq '50345.5'
expect(sub_guide_card.path).to eq '9/0091/A3067'
expect(sub_guide_card.guide_card.class).to eq GuideCard
end
end
3 changes: 1 addition & 2 deletions spec/services/sub_guide_loading_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

it 'imports all data from the CSV file' do
expect(SubGuideCard.count).to eq 0
new_guide_card = GuideCard.new
sgls.import(parent_guide: new_guide_card)
sgls.import
expect(SubGuideCard.count).to eq 5
end
end