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

WIP 캠페인즈 아카이브 이전 #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions app/models/sewol_data_detail.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class SewolDataDetail < ApplicationRecord
belongs_to :data_set
end
20 changes: 20 additions & 0 deletions db/migrate/20210807020807_create_sewol_data_details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class CreateSewolDataDetails < ActiveRecord::Migration[5.2]
def change
create_table :sewol_data_details do |t|
t.string :content
t.string :content_name
t.string :content_type
t.integer :content_size
t.string :media_type
t.string :category_slug
t.string :content_source
t.string :content_recipients
t.string :donor
t.boolean :is_secret_donor
t.string :content_created_date
t.string :content_created_time
t.belongs_to :data_set, foreign_key: true
t.timestamps
end
end
end
22 changes: 21 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_11_16_105613) do
ActiveRecord::Schema.define(version: 2021_08_07_020807) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -105,6 +105,25 @@
t.index ["user_id"], name: "index_rumors_on_user_id"
end

create_table "sewol_data_details", force: :cascade do |t|
t.string "content"
t.string "content_name"
t.string "content_type"
t.integer "content_size"
t.string "media_type"
t.string "category_slug"
t.string "content_source"
t.string "content_recipients"
t.string "donor"
t.boolean "is_secret_donor"
t.string "content_created_date"
t.string "content_created_time"
t.bigint "data_set_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["data_set_id"], name: "index_sewol_data_details_on_data_set_id"
end

create_table "taggings", id: :serial, force: :cascade do |t|
t.integer "tag_id"
t.string "taggable_type"
Expand Down Expand Up @@ -170,5 +189,6 @@
add_foreign_key "posts", "archives"
add_foreign_key "posts", "users"
add_foreign_key "rumors", "users"
add_foreign_key "sewol_data_details", "data_sets"
add_foreign_key "taggings", "tags"
end
68 changes: 68 additions & 0 deletions lib/tasks/sewol.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
require 'csv'

namespace :sewol do
task :fetch => :environment do
user = User.find_by(name: 'jay')

ActiveRecord::Base.transaction do
archive = Archive.create!(title: "세월호 아카이브", body: "세월호 아카이브",
user: user, slug: "sewolarchive", publisher: "사회적협동조합 빠띠")

count = 1
CSV.foreach('tmp/archive_documents.csv', headers: true) do |row|
puts "================="
puts "row: #{row.inspect}"

dataset = DataSet.create!(
title: row['title'], body: row['body'],
user: user,
created_at: row['created_at'],
updated_at: row['updated_at'],
url: 'https://parti.coop', # TODO 나중에는 RF - 타입에 따른 validation
archive: archive,
publisher: row['content_creator'],
)

sewoldata = SewolDataDetail.create!(
content_created_time: row['content_created_time'],
content_source: row['content_source'],
content: row['content'],
content_name: row['content_name'],
content_type: row['content_type'],
content_size: row['content_size'],
category_slug: row['category_slug'],
media_type: row['media_type'],
content_created_date: row['content_created_date'],
content_recipients: row['content_recipients'],
donor: row['donor'],
is_secret_donor: row['is_secret_donor'],
data_set_id: dataset
)

# 외부DataDetail
# NgoDataDetail...........
print '.'
puts if count > 80
count = count + 1
break if count > 300

# puts "dataset: #{dataset.inspect}"
# puts "sewoldatadetail: #{sewoldata.inspect}"
end
end
end
end

# SewolSource
# "publisher" <= ArchiveDocument#"content_creator" ex) 소방방재청
# "file_type"=> ExeternalSource
# "properties”=> ExeternalSource
# "data_created_at"<= ArchiveDocument#"content_created_time"
# "data_updated_at"???
# "license"
# "memo"
# "tag_list"


# --
# "donor":"국회 세월호 국정조사 특위
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "datapublic",
"private": true,
"dependencies": {}
"dependencies": {},
"version": "0.0.0"
}