Skip to content

Commit

Permalink
Turned linkify_haarchion into a rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
abartov committed Aug 12, 2024
1 parent c580300 commit e33a6b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
20 changes: 20 additions & 0 deletions lib/tasks/linkify_haarchion.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'csv'

desc 'Import Haarchion audio links from CSV'
task :linkify_haarchion, [:csv_file] => :environment do |taskname, args|
lines = CSV.read(args.csv_file)[1..-1] # skip header row
puts "Creating links for #{lines.size} records..."
lines.each do |line|
mid = line[4][line[4].rindex('/') + 1..-1]
next if ExternalLink.exists?(url: line[5], linkable_id: mid,
linkable_type: 'Manifestation')

ExternalLink.create!(url: line[5],
description: 'להקראת היצירה באתר הארכיון - ספרות עברית בקול',
status: :approved,
linktype: :audio,
linkable_id: mid,
linkable_type: 'Manifestation')
end
puts 'done.'
end
17 changes: 0 additions & 17 deletions util/linkify_haarchion.rb

This file was deleted.

0 comments on commit e33a6b8

Please sign in to comment.