diff --git a/app/models/character.rb b/app/models/character.rb
index 9796d7d..fc8f13a 100644
--- a/app/models/character.rb
+++ b/app/models/character.rb
@@ -1,2 +1,3 @@
class Character < ApplicationRecord
+ belongs_to :star
end
diff --git a/app/models/character_to_star.rb b/app/models/character_to_star.rb
deleted file mode 100644
index cf7e29b..0000000
--- a/app/models/character_to_star.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-class CharacterToStar < ApplicationRecord
-end
diff --git a/app/models/star.rb b/app/models/star.rb
index 1bfe1b2..3c9a2c8 100644
--- a/app/models/star.rb
+++ b/app/models/star.rb
@@ -1,143 +1,3 @@
class Star < ApplicationRecord
- # def self.foo
- # stars = [
- # '天魁星・呼保義・宋江(てんかいせい・こほうぎ・そうこう)',
- # '天罡星・玉麒麟・盧俊義(てんこうせい・ぎょくきりん・ろしゅんぎ)',
- # '天機星・智多星・吾用(てんきせい・ちたせい・ごよう)',
- # '天間星・入雲竜・公孫勝(てんかんせい・にゅううんりゅう・こうそんしょう)',
- # '天勇星・大刀・関勝(てんゆうせい・だいとう・かんしょう)',
- # '天雄星・豹子頭・林冲(てんゆうせい・ひょうしとう・りんちゅう)',
- # '天猛星・霹靂火・秦明(てんもうせい・へきれきか・しんめい)',
- # '天威星・双鞭・呼延灼(てんいせい・そうべん・こえんしゃく)',
- # '天英星・小李広・花栄(てんえいせい・しょうりこう・かえい)',
- # '天貴星・小旋風・柴進(てんきせい・しょうせんぷう・さいしん)',
- # '天富星・撲天鵰・李応(てんふうせい・はくてんちょう・りおう)',
- # '天満星・美髯公・朱仝(てんまんせい・びぜんこう・しゅどう)',
- # '天孤星・花和尚・魯智深(てんこせい・かおうしょう・ろちしん)',
- # '天傷星・行者・武松(てんしょうせい・ぎょうじゃ・ぶしょう)',
- # '天立星・双鎗将・董平(てんりつせい・そうそうしょう・とうへい)',
- # '天捷星・没羽箭・張清(てんしょうせい・ぼつうせん・ちょうせい)',
- # '天暗星・青面獣・楊志(てんあんせい・せいめんじゅう・ようし)',
- # '天祐星・金鎗手・徐寧(てんゆうせい・きんそうしゅ・じょねい)',
- # '天空星・急先鋒・索超(てんくうせい・きゅうせんぽう・さくちょう)',
- # '天速星・神行太保・戴宗(しんそくせい・しんこうたいほう・たいそう)',
- # '天異星・赤髪鬼・劉唐(てんいせい・せきはつき・りゅうとう)',
- # '天殺星・黒旋風・李逵(てんさつせい・こくせんぷう・りき)',
- # '天微星・九紋竜・史進(てんびせい・くもんりゅう・ししん)',
- # '天究星・没遮攔・穆弘(てんきゅうせい・ぼつしゃらん・ぼくこう)',
- # '天退星・插翅虎・雷横(てんたいせい・そうしこ・らいおう)',
- # '天寿星・混江竜・李俊(てんじゅせい・こんこうりゅう・りしゅん)',
- # '天剣星・立地太歳・阮小二(てんけんせい・りっちたいさい・げんしょうじ)',
- # '天平星・船火児・張横(てんぺいせい・せんかじ・ちょうおう)',
- # '天罪星・短命二郎・阮小五(てんざいせい・たんめいじろう・げんしょうご)',
- # '天損星・浪裏白跳・張順(てんそんせい・ろうりはくちょう・ちょうじゅん)',
- # '天敗星・活閻羅・阮小七(てんはいせい・かつえんら・げんしょうしち)',
- # '天牢星・病関索・楊雄(てんろうせい・びょうかんさく・ようゆう)',
- # '天慧星・拚命三郎・石秀(てんけいせい・へんめいさんろう・せきしゅう)',
- # '天暴星・両頭蛇・解珍(てんぼうせい・りょうとうだ・かいちん)',
- # '天哭星・双尾蝎・解宝(てんこくせい・そうびかつ・かいほう)',
- # '天巧星・浪子・燕青(てんこうせい・ろうし・えんせい)',
- # '地魁星・神機軍師・朱武(ちかいせい・しんきぐんし・しゅぶ)',
- # '地煞星・鎮三山・黄信(ちさつせい・ちんさんざん・こうしん)',
- # '地勇星・病尉遅・孫立(ちゆうせい・びょううつち・そんりつ)',
- # '地傑星・醜郡馬・宣贊(ちけつせい・しゅうぐんば・せんさん)',
- # '地雄星・井木犴・郝思文(ちゆうせい・せいぼくかん・かくしぶん)',
- # '地威星・百勝将・韓滔(ちいせい・ひゃくしょうしょう・かんとう)',
- # '地英星・天目将・彭玘(ちえいせい・てんもくしょう・ほうき)',
- # '地奇星・聖水将・単廷珪(ちきせい・せいすいしょう・ぜんていけい)',
- # '地猛星・神火将・魏定国(ちもうせい・しんかしょう・ぎていこく)',
- # '地文星・聖手書生・蕭譲(ちぶんせい・せいしゅしょせい・しょうじょう)',
- # '地正星・鉄面孔目・裴宣(ちせいせい・てつめんこうもく・はいせん)',
- # '地闊星・摩雲金翅・欧鵬(ちかつせい・まうんきんし・おうほう)',
- # '地闘星・火眼狻猊・鄧飛(ちとうせい・かがんしゅんげい・とうひ)',
- # '地強星・錦毛虎・燕順(ちきょうせい・きんもうこ・えんじゅん)',
- # '地暗星・錦豹子・楊林(ちあんせい・きんひょうし・ようりん)',
- # '地軸星・轟天雷・凌振(ちじくせい・ごうてんらい・りょうしん)',
- # '地会星・神算子・蒋敬(ちかいせい・しんさんし・しょうけい)',
- # '地佐星・小温侯・呂方(ちさせい・しょうおんこう・りょほう)',
- # '地祐星・賽仁貴・郭盛(ちゆうせい・さいじんき・かくせい)',
- # '地霊星・神医・安道全(ちれいせい・しんい・あんどうぜん)',
- # '地獣星・紫髯伯・皇甫端(ちじゅうせい・しぜんはく・こうほたん)',
- # '地微星・矮脚虎・王英(ちびせい・わいきゃくこ・おうえい)',
- # '地急星・一丈青・扈三娘(ちきゅうせい・いちじょうせい・こさんじょう)',
- # '地暴星・喪門神・鮑旭(ちぼうせい・そうもんしん・ほうきょく)',
- # '地然星・混世魔王・樊瑞(ちぜんせい・こんせいまおう・はんずい)',
- # '地好星・毛頭星・孔明(ちこうせい・もうとうせい・こうめい)',
- # '地狂星・独火星・孔亮(ちきょうせい・どくかせい・こうりょう)',
- # '地飛星・八臂那タ・項充(ちひせい・はっぴなた・こうじゅう)',
- # '地走星・飛天大聖・李袞(ちそうせい・ひてんたいせい・りこん)',
- # '地巧星・玉臂匠・金大堅(ちこうせい・ぎょくひしょう・きんたいけん)',
- # '地明星・鉄笛仙・馬麟(ちめいせい・てつてきせん・ばりん)',
- # '地進星・出洞蛟・童威(ちしんせい・しゅつどうこう・どうい)',
- # '地退星・翻江蜃・童猛(ちたいせい・ほんこうしん・どうもう)',
- # '地満星・玉旛竿・孟康(ちまんせい・ぎょくはんかん・もうこう)',
- # '地遂星・通臂猿・侯健(ちすいせい・つうひえん・こうけん)',
- # '地周星・跳澗虎・陳達(ちしゅうせい・ちょうかんこ・ちんたつ)',
- # '地隠星・白花蛇・揚春(ちいんせい・はくかだ・ようしゅん)',
- # '地異星・白面郎君・鄭天寿(ちいせい・はくめんろうくん・ていてんじゅ)',
- # '地理星・九尾亀・陶宗旺(ちりせい・きゅうびき・とうそうおう)',
- # '地俊星・鉄扇子・宋清(ちしゅんせい・てつせんし・そうせい)',
- # '地楽星・鉄叫子・楽和(ちがくせい・てつきょうし・がくわ)',
- # '地捷星・花項虎・龔旺(ちしょうせい・かこうこ・きょうおう)',
- # '地速星・中箭虎・丁得孫(ちそくせい・ちゅうせんこ・ていとくそん)',
- # '地鎮星・小遮攔・穆春(ちちんせい・しょうしゃらん・ぼくしゅん)',
- # '地稽星・操刀鬼・曹正(ちけいせい・そうとうき・そうせい)',
- # '地魔星・雲裏金剛・宋万(ちませい・うんりこんごう・そうまん)',
- # '地妖星・摸着天・杜遷(ちようせい・もちゃくてん・とせん)',
- # '地幽星・病大虫・薛永(ちゆうせい・びょうたいちゅう・せつえい)',
- # '地伏星・金眼彪・施恩(ちふくせい・きんがんひょう・しおん)',
- # '地僻星・打虎将・李忠(ちへきせい・だこしょう・りちゅう)',
- # '地空星・小覇王・周通(ちくうせい・しょうはおう・しゅうとう)',
- # '地孤星・金銭豹子・湯隆(ちこせい・きんせんひょうし・とうりゅう)',
- # '地全星・鬼臉児・杜興(ちぜんせい・きれんじ・とこう)',
- # '地短星・出林竜・鄒淵(ちたんせい・しゅつりんりゅう・すうえん)',
- # '地角星・独角竜・鄒潤(ちかくせい・どくかくりゅう・すうじゅん)',
- # '地囚星・旱地忽律・朱貴(ちしゅうせい・かんちこつりつ・しゅき)',
- # '地蔵星・笑面虎・朱富(ちぞうせい・しょうめんこ・しゅふう)',
- # '地平星・鉄臂膊・蔡福(ちへいせい・てっぴはく・さいふく)',
- # '地損星・一枝花・蔡慶(ちそんせい・いっしか・さいけい)',
- # '地奴星・催命判官・李立(ちどせい・さいめいはんがん・りりつ)',
- # '地察星・青眼虎・李雲(ちさつせい・せいがんこ・りうん)',
- # '地悪星・没面目・焦挺(ちあくせい・ぼつめんもく・しょうてい)',
- # '地醜星・石将軍・石勇(ちしゅうせい・せきしょうぐん・せきゆう)',
- # '地数星・小尉遅・孫新(ちすうせい・しょううつち・そんしん)',
- # '地陰星・母大虫・顧大嫂(ちいんせい・ぼたいちゅう・こだいそう)',
- # '地刑星・菜園子・張青(ちけいせい・さいえんし・ちょうせい)',
- # '地壮星・母夜叉・孫二娘(ちそうせい・ぼやしゃ・そんじじょう)',
- # '地劣星・活閃婆・王定六(ちれつせい・かつせんば・おうていろく)',
- # '地健星・剣道神・郁保四(ちけんせい・けんどうしん・いくほうし)',
- # '地耗星・白日鼠・白勝(ちこうせい・はくじつそ・はくしょう)',
- # '地賊星・鼓上蚤・時遷(ちぞくせい・こじょうそう・じせん)',
- # '地狗星・金毛犬・段景住(ちくせい・きんもうけん・だんけいじゅう)',
- # ]
-
- # rank = 0
- # results = stars.map do |star|
- # binding.break if star.match(/(.*)(.*)/).nil?
- # kanji_part = star.match(/(.*)(.*)/)[1]
- # kanjis = kanji_part.split('・')
-
- # kana_part = star.match(/(.*)((.*))/)[2]
- # kanas = kana_part.split('・')
-
- # rank += 1
- # {
- # rank:,
- # kanji: {
- # star_name: kanjis[0],
- # nickname: kanjis[1],
- # name: kanjis[2]
- # },
- # kana: {
- # star_name: kanas[0],
- # nickname: kanas[1],
- # name: kanas[2]
- # }
- # }
- # end
-
- # File.write('hoge.json', JSON.pretty_generate(results))
-
- # binding.irb
- # end
+ has_many :characters
end
diff --git a/app/service/import_service/character.rb b/app/service/import_service/character.rb
index 53f2780..99bc339 100644
--- a/app/service/import_service/character.rb
+++ b/app/service/import_service/character.rb
@@ -1,45 +1,63 @@
module ImportService
class Character < Base
+ NUMBER_OF_SOD = 108
+
def rows # rubocop:disable Metrics/AbcSize
rows = []
- # 時間が掛かるが順番を優先する
- on_sheet_characters = ::OnSheet::Character.all
-
- on_sheet_s1_characters = on_sheet_characters.pluck(:s1)
- on_sheet_s1_yomis = on_sheet_characters.pluck(:s1_yomi)
- on_sheet_s1_ens = on_sheet_characters.pluck(:s1_en)
- rows += on_sheet_s1_characters.zip(on_sheet_s1_yomis, on_sheet_s1_ens)
-
- on_sheet_s2_characters = on_sheet_characters.pluck(:s2)
- on_sheet_s2_yomis = on_sheet_characters.pluck(:s2_yomi)
- on_sheet_s2_ens = on_sheet_characters.pluck(:s2_en)
- rows += on_sheet_s2_characters.zip(on_sheet_s2_yomis, on_sheet_s2_ens)
-
- on_sheet_s3_characters = on_sheet_characters.pluck(:s3)
- on_sheet_s3_yomis = on_sheet_characters.pluck(:s3_yomi)
- on_sheet_s3_ens = on_sheet_characters.pluck(:s3_en)
- rows += on_sheet_s3_characters.zip(on_sheet_s3_yomis, on_sheet_s3_ens)
-
- on_sheet_s4_characters = on_sheet_characters.pluck(:s4)
- on_sheet_s4_yomis = on_sheet_characters.pluck(:s4_yomi)
- on_sheet_s4_ens = on_sheet_characters.pluck(:s4_en)
- rows += on_sheet_s4_characters.zip(on_sheet_s4_yomis, on_sheet_s4_ens)
-
- on_sheet_s5_characters = on_sheet_characters.pluck(:s5)
- on_sheet_s5_yomis = on_sheet_characters.pluck(:s5_yomi)
- on_sheet_s5_ens = on_sheet_characters.pluck(:s5_en)
- rows += on_sheet_s5_characters.zip(on_sheet_s5_yomis, on_sheet_s5_ens)
-
- on_sheet_tk_characters = on_sheet_characters.pluck(:tk)
- on_sheet_tk_yomis = on_sheet_characters.pluck(:tk_yomi)
- on_sheet_tk_ens = on_sheet_characters.pluck(:tk_en)
- rows += on_sheet_tk_characters.zip(on_sheet_tk_yomis, on_sheet_tk_ens)
-
- on_sheet_woven_characters = on_sheet_characters.pluck(:woven)
- on_sheet_woven_yomis = on_sheet_characters.pluck(:woven_yomi)
- on_sheet_woven_ens = on_sheet_characters.pluck(:woven_en)
- rows += on_sheet_woven_characters.zip(on_sheet_woven_yomis, on_sheet_woven_ens)
+ NUMBER_OF_SOD.times do |i|
+ index_number = i + 1
+ on_sheet_character = ::OnSheet::Character.find_by(id: index_number)
+
+ s1_star_name = on_sheet_character.star_attr
+ s1_star_foreign_key_id = ::Star.find_by(name: s1_star_name).id
+ s1_character = on_sheet_character.s1
+ s1_yomi = on_sheet_character.s1_yomi
+ s1_en = on_sheet_character.s1_en
+ rows << [s1_star_foreign_key_id, s1_character, s1_yomi, s1_en]
+
+ s2_star_name = on_sheet_character.star_attr
+ s2_star_foreign_key_id = ::Star.find_by(name: s2_star_name).id
+ s2_character = on_sheet_character.s2
+ s2_yomi = on_sheet_character.s2_yomi
+ s2_en = on_sheet_character.s2_en
+ rows << [s2_star_foreign_key_id, s2_character, s2_yomi, s2_en]
+
+ s3_star_name = on_sheet_character.star_attr
+ s3_star_foreign_key_id = ::Star.find_by(name: s3_star_name).id
+ s3_character = on_sheet_character.s3
+ s3_yomi = on_sheet_character.s3_yomi
+ s3_en = on_sheet_character.s3_en
+ rows << [s3_star_foreign_key_id, s3_character, s3_yomi, s3_en]
+
+ s4_star_name = on_sheet_character.star_attr
+ s4_star_foreign_key_id = ::Star.find_by(name: s4_star_name).id
+ s4_character = on_sheet_character.s4
+ s4_yomi = on_sheet_character.s4_yomi
+ s4_en = on_sheet_character.s4_en
+ rows << [s4_star_foreign_key_id, s4_character, s4_yomi, s4_en]
+
+ s5_star_name = on_sheet_character.star_attr
+ s5_star_foreign_key_id = ::Star.find_by(name: s5_star_name).id
+ s5_character = on_sheet_character.s5
+ s5_yomi = on_sheet_character.s5_yomi
+ s5_en = on_sheet_character.s5_en
+ rows << [s5_star_foreign_key_id, s5_character, s5_yomi, s5_en]
+
+ tk_star_name = on_sheet_character.star_attr
+ tk_star_foreign_key_id = ::Star.find_by(name: tk_star_name).id
+ tk_character = on_sheet_character.tk
+ tk_yomi = on_sheet_character.tk_yomi
+ tk_en = on_sheet_character.tk_en
+ rows << [tk_star_foreign_key_id, tk_character, tk_yomi, tk_en]
+
+ woven_star_name = on_sheet_character.star_attr
+ woven_star_foreign_key_id = ::Star.find_by(name: woven_star_name).id
+ woven_character = on_sheet_character.woven
+ woven_yomi = on_sheet_character.woven_yomi
+ woven_en = on_sheet_character.woven_en
+ rows << [woven_star_foreign_key_id, woven_character, woven_yomi, woven_en]
+ end
rows
end
diff --git a/app/service/import_service/character_to_star.rb b/app/service/import_service/character_to_star.rb
deleted file mode 100644
index 3795e62..0000000
--- a/app/service/import_service/character_to_star.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module ImportService
- class CharacterToStar < Base
- def rows
- # 前提として Character と Star にデータが収まっていること
- # characters = ::Character.all
- # stars = ::Star.all
- end
- end
-end
diff --git a/app/service/import_service/star.rb b/app/service/import_service/star.rb
index b01fde4..84affc9 100644
--- a/app/service/import_service/star.rb
+++ b/app/service/import_service/star.rb
@@ -1,20 +1,14 @@
module ImportService
class Star < Base
def rows
- JSON.parse(
- File.read('db/json/stars.json')
- )
-
- # resources = JSON.parse(File.read('db/json/stars.json'))
-
- # binding.break
-
- # seating_orders = on_sheet_stars.map(&:seating_order)
- # names = on_sheet_stars.map(&:name)
- # yomis = on_sheet_stars.count.times.map { |_| '' }
- # name_ens = on_sheet_stars.map(&:name_en)
-
- # seating_orders.zip(names, yomis, name_ens)
+ ::OnSheet::Star.all.map do |on_sheet_star|
+ [
+ on_sheet_star.seating_order,
+ on_sheet_star.name,
+ on_sheet_star.yomi,
+ on_sheet_star.name_en,
+ ]
+ end
end
end
end
diff --git a/db/csv_on_sheet/basic_attributes/stars.csv b/db/csv_on_sheet/basic_attributes/stars.csv
index 9569085..3b985f0 100644
--- a/db/csv_on_sheet/basic_attributes/stars.csv
+++ b/db/csv_on_sheet/basic_attributes/stars.csv
@@ -1,4 +1,4 @@
-id,seating_order,category,name,name_kana,name_en
+id,seating_order,category,name,yomi,name_en
1,1,0,天魁星,てんかいせい,Leader Star
2,2,0,天罡星,てんこうせい,Strength Star
3,3,0,天機星,てんきせい,Knowledge Star
diff --git a/db/csv_on_sheet/characters/bases.csv b/db/csv_on_sheet/characters/bases.csv
index c693477..552407c 100644
--- a/db/csv_on_sheet/characters/bases.csv
+++ b/db/csv_on_sheet/characters/bases.csv
@@ -1,6 +1,6 @@
id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en,s5,s5_yomi,s5_en,tk,tk_yomi,tk_en,woven,woven_yomi,woven_en,water_margin,water_margin_yomi,water_margin_en
-1,天魁星,I主人公,わんしゅじんこう,Hero,II主人公,"",Herp,トーマス,"",Thomas,IV主人公,"",Hero,王子,"",Hero,主人公,"",Hero,主人公,"","",宋江,そうこう
-2,天罡星,レパント,れぱんと,Lepant,リドリー・ワイゼン / ボリス・ワイゼン,"",Ridley/Boris,ササライ,"",Sasarai,リノ・エン・クルデス,"",Lino En Kuldes,ラージャ,"",Raja,ダイアルフ,"",Diulf,ジャグワン,"","",盧俊義
+1,天魁星,I主人公,わんしゅじんこう,Hero,II主人公,"",Herp,トーマス,"",Thomas,IV主人公,"",Hero,王子,"",Hero,TK主人公,"",Hero,紡時主人公,"","",宋江,そうこう
+2,天罡星,レパント,れぱんと,Lepant,"リドリー・ワイゼン,ボリス・ワイゼン","",Ridley/Boris,ササライ,"",Sasarai,リノ・エン・クルデス,"",Lino En Kuldes,ラージャ,"",Raja,ダイアルフ,"",Diulf,ジャグワン,"","",盧俊義
3,天機星,マッシュ・シルバーバーグ,まっしゅしるばーばーぐ,Mathiu,シュウ,"",Shu,シーザー・シルバーバーグ,"",Caesar Silverberg,エレノア・シルバーバーグ,"",Elenor,ルクレティア・メルセス,"",Lucretia Merces,リウ,"",Liu,レギウス,"","",呉用
4,天間星,ルック,"",Luc,ルック,"",Luc,ルック,"",Luc,テッド,"",Ted,ゼラセ,"",Zerase,ゼノア,"",Zenoa,ゼフォン,"","",公孫勝
5,天勇星,ハンフリー・ミンツ,"",Humphrey,ハンフリー・ミンツ,"",Humphrey,デュパ,"",Dupa,タル,"",Tal,クレイグ・ラーデン,"",Craig Laden,オルドヴィーク,"",Ordovic,ゴンボスレン,"","",関勝
@@ -9,10 +9,10 @@ id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en
8,天威星,ペシュメルガ,"",Pesmerga,ペシュメルガ,"",Pesmerga,ルシア,"",Lucia,セルマ,"",Selma,ナクラ,"",Nakula,エヌムクラウ,"",Enumclaw,モーディ,"","",呼延灼
9,天英星,グレミオ,"",Gremio,シエラ,"",Sierra,ユイリ,"",Yuiri,アルド,"",Aldo,リオン,"",Lyon,マリカ,"",Marica,ミュラ,"","",花栄
10,天貴星,ウォーレン,"",Warren,テレーズ,"",Teresa,サロメ・ハラス,"",Salome,ラインバッハ,"",Reinbach,タルゲイユ,"",Talgeyl,ネイラ,"",Neira,ラスカリス,"","",柴進
-11,天富星,クン・トー,"",Kun To,ニナ,"",Nina,ジンバ,"",Jimba,チープー,"",Chiepoo,エレシュ / ユーラム・バロウズ,"",Eresh / Euram Barows,レスノウ,"",Resno,リュセリ,"","",李応
-12,天満星,クレオ,"",Cleo,アビズボア / フェザー / ジークフリート,"",Abizboah / Feather / Sigfried,ジョアン,"",Joanne,ポーラ,"",Paula,ダイン,"",Dinn,ディアドラ,"",Diadora,ユディエラ,"","",朱仝
+11,天富星,クン・トー,"",Kun To,ニナ,"",Nina,ジンバ,"",Jimba,チープー,"",Chiepoo,"エレシュ,ユーラム・バロウズ","",Eresh / Euram Barows,レスノウ,"",Resno,リュセリ,"","",李応
+12,天満星,クレオ,"",Cleo,"アビズボア,フェザー,ジークフリート","",Abizboah / Feather / Sigfried,ジョアン,"",Joanne,ポーラ,"",Paula,ダイン,"",Dinn,ディアドラ,"",Diadora,ユディエラ,"","",朱仝
13,天孤星,ビクトール,"","",ビクトール,"","",ジョー軍曹,"","",キカ,"","",カイル,"","",ルバイス,"","",デューカス,"","",魯智深
-14,天傷星,バレリア,"","",バレリア / トモ,"","",ヒューゴ,"","",ケネス,"","",ゼガイ,"","",ベレムエル,"","",ツェレンドラム,"","",武松
+14,天傷星,バレリア,"","","バレリア,トモ","","",ヒューゴ,"","",ケネス,"","",ゼガイ,"","",ベレムエル,"","",ツェレンドラム,"","",武松
15,天立星,グリフィス,"","",フィッチャー,"","",バズバ,"","",ラマダ,"","",イサト,"","",ゲシュッツ,"","",シャルフ,"","",董平
16,天捷星,クライブ,"","",クライブ,"","",ユン,"","",トラヴィス,"","",ハスワール,"","",ザイン,"","",フォルネ,"","",張清
17,天暗星,フリック,"","",フリック,"","",エッジ,"","",スノウ・フィンガーフート,"",Snowe,ベルクート,"","",ルオ・タウ,"","",オゥヤー,"","",楊志
@@ -23,7 +23,7 @@ id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en
22,天殺星,フー・スー・ルー,"","",ハンナ,"","",ハレック,"","",ゴー,"","",エルンスト,"","",ボッシュ,"","",ウッツェ,"","",李逵
23,天微星,キルキス,"","",キリィ,"","",クリス・ライトフェロー,"","",グレッチェン,"","",キリィ,"","",スフィール,"","",ニド,"","",史進
24,天究星,ミルイヒ・オッペンハイマー,"","",アニタ,"","",エステラ,"","",コンラッド,"","",シュラ・ヴァルヤ,"","",セレン,"","",ヤンセン,"","",穆弘
-25,天退星,パーン,"","",アビズボア / フェザー / ジークフリート,"","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横
+25,天退星,パーン,"","","アビズボア,フェザー,ジークフリート","","",セシル,"","",ジュエル,"","",シュン,"","",ジェイル,"","",ジーノ,"","",雷横
26,天寿星,ソニア・シューレン,"","",ナナミ,"","",ゲド,"","",カタリナ,"","",ベルナデット・イーガン,"","",ラジム,"","",イリア,"","",李俊
27,天剣星,アンジー,"","",リィナ,"","",メルヴィル,"","",ロウセン,"","",ヴォリガ,"","",ドロモン,"","",スニル,"","",阮小二
28,天平星,タイ・ホー,"","",タイ・ホー,"","",エース,"","",シラミネ,"","",ランス,"","",クロデキルド,"","",グワイニー,"","",張横
@@ -57,10 +57,10 @@ id,star_attr,s1,s1_yomi,s1_en,s2,s2_yomi,s2_en,s3,s3_yomi,s3_en,s4,s4_yomi,s4_en
56,地霊星,リュウカン,"","",ホウアン,"","",ミオ,"","",ユウ,"","",シルヴァ,"","",ユーニス,"","",キアロ,"","",安道全
57,地獣星,フッケン,"","",トウタ,"","",トウタ,"","",キャリー,"","",ムラード,"","",ザフラー,"","",オド,"","",皇甫端
58,地微星,フッチ,"","",フッチ,"","",フッチ,"","",ダリオ,"","",ガヴァヤ,"","",タージ,"","",ムーイー,"","",王英
-59,地慧星,カスミ,"","",カスミ / トモ,"","",リリィ,"","",ミレイ,"","",ハヅキ,"","",ユラ,"","",シルディス,"","",扈三娘
+59,地急星,カスミ,"","","カスミ,トモ","","",リリィ,"","",ミレイ,"","",ハヅキ,"","",ユラ,"","",シルディス,"","",扈三娘
60,地暴星,マース,"","",バド,"","",ジェファーソン,"","",ラインホルト,"","",モルーン,"","",ノムノ,"","",ソウ,"","",鮑旭
61,地然星,クロウリー,"","",メイザース,"","",セラ,"","",ウォーロック,"","",レヴィ,"","",ヌザート,"","",ユユドラヤ,"","",樊瑞
-62,地猖星,フウマ,"","",モンド,"","",ワタリ,"","",アカギ,"","",シグレ,"","",サーヴィラ,"","",サティヤカ,"","",孔明
+62,地好星,フウマ,"","",モンド,"","",ワタリ,"","",アカギ,"","",シグレ,"","",サーヴィラ,"","",サティヤカ,"","",孔明
63,地狂星,ムース,"","",サスケ,"","",アヤメ,"","",ミズキ,"","",サギリ,"","",リュキア,"","",フリディカ,"","",孔亮
64,地飛星,ミース,"","",レオナ,"","",セバスチャン,"","",オルナン,"","",マリノ,"","",コウ・ロー,"","",ニクンバ,"","",項充
65,地走星,セルゲイ,"","",アダリー,"","",シズ,"","",マニュ,"","",バベッジ,"","",バルザム,"","",サウ,"","",李袞
diff --git a/db/erd.dot b/db/erd.dot
index 39b6860..175ed6d 100644
--- a/db/erd.dot
+++ b/db/erd.dot
@@ -22,19 +22,10 @@ m_Character [label = <
id integer (8) PK |
name string ∗ |
name_en string ∗ |
+ star_id integer (8) ∗ FK |
yomi string ∗ |
>];
-m_CharacterToStar [label = <
-|
-
- character_id integer (8) ∗ |
- id integer (8) PK |
- star_id integer (8) ∗ |
-
->];
"m_Gss::Character" [label = <
@@ -155,8 +146,8 @@ m_CharacterToStar [label = <id integer (8) PK |
name string |
name_en string |
- name_kana string |
seating_order string |
+ yomi string |
>];
"m_OnSheet::Title" [label = <
@@ -181,4 +172,5 @@ m_Star [label = <
>];
+ m_Star -> m_Character [arrowsize = "0.6", arrowhead = "dotnormal", arrowtail = "odot", weight = "2"];
}
diff --git a/db/erd.pdf b/db/erd.pdf
index 3f43877..503f45c 100644
Binary files a/db/erd.pdf and b/db/erd.pdf differ
diff --git a/db/erd.png b/db/erd.png
index d9896de..7d344a7 100644
Binary files a/db/erd.png and b/db/erd.png differ
diff --git a/db/migrate/20230703094010_create_on_sheet_stars.rb b/db/migrate/20230703094010_create_on_sheet_stars.rb
index ee7e52e..930a22d 100644
--- a/db/migrate/20230703094010_create_on_sheet_stars.rb
+++ b/db/migrate/20230703094010_create_on_sheet_stars.rb
@@ -4,7 +4,7 @@ def change
t.string :seating_order, null: true, comment: '108星の順番'
t.integer :category, null: false, comment: '(enum) 天罡星三十六星 or 地煞星七十二星'
t.string :name, null: true, comment: '108星の名前'
- t.string :name_kana, null: true, comment: '108星の名前(読み仮名)'
+ t.string :yomi, null: true, comment: '108星の名前(読み仮名)'
t.string :name_en, null: true, comment: '108星の英語名'
t.timestamps
diff --git a/db/migrate/20230705125445_create_stars.rb b/db/migrate/20230705123445_create_stars.rb
similarity index 100%
rename from db/migrate/20230705125445_create_stars.rb
rename to db/migrate/20230705123445_create_stars.rb
diff --git a/db/migrate/20230705124857_create_characters.rb b/db/migrate/20230705124857_create_characters.rb
index 335dfba..e71c26e 100644
--- a/db/migrate/20230705124857_create_characters.rb
+++ b/db/migrate/20230705124857_create_characters.rb
@@ -1,6 +1,8 @@
class CreateCharacters < ActiveRecord::Migration[7.0]
def change
create_table :characters do |t|
+ t.references :star, null: false, foreign_key: true, comment: '宿星'
+
t.string :name, null: false, default: '', comment: 'キャラ名(「極」に準ずる)'
t.string :yomi, null: false, default: '', comment: 'キャラ名の読み仮名'
t.string :name_en, null: false, default: '', comment: 'キャラ名(英語)'
diff --git a/db/migrate/20230705125613_create_character_to_stars.rb b/db/migrate/20230705125613_create_character_to_stars.rb
deleted file mode 100644
index 004f808..0000000
--- a/db/migrate/20230705125613_create_character_to_stars.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-class CreateCharacterToStars < ActiveRecord::Migration[7.0]
- def change
- create_table :character_to_stars do |t|
- t.references :character, null: false, foreign_key: true, comment: 'キャラクター'
- t.references :star, null: false, foreign_key: true, comment: '108星'
-
- t.timestamps
- end
- end
-end
diff --git a/db/schema.rb b/db/schema.rb
index 33930b3..2c6dcb0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -14,21 +14,14 @@
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- create_table "character_to_stars", force: :cascade do |t|
- t.bigint "character_id", null: false, comment: "キャラクター"
- t.bigint "star_id", null: false, comment: "108星"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
- t.index ["character_id"], name: "index_character_to_stars_on_character_id"
- t.index ["star_id"], name: "index_character_to_stars_on_star_id"
- end
-
create_table "characters", force: :cascade do |t|
+ t.bigint "star_id", null: false, comment: "宿星"
t.string "name", default: "", null: false, comment: "キャラ名(「極」に準ずる)"
t.string "yomi", default: "", null: false, comment: "キャラ名の読み仮名"
t.string "name_en", default: "", null: false, comment: "キャラ名(英語)"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
+ t.index ["star_id"], name: "index_characters_on_star_id"
end
create_table "gss_characters", force: :cascade do |t|
@@ -130,7 +123,7 @@
t.string "seating_order", comment: "108星の順番"
t.integer "category", null: false, comment: "(enum) 天罡星三十六星 or 地煞星七十二星"
t.string "name", comment: "108星の名前"
- t.string "name_kana", comment: "108星の名前(読み仮名)"
+ t.string "yomi", comment: "108星の名前(読み仮名)"
t.string "name_en", comment: "108星の英語名"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -155,6 +148,5 @@
t.datetime "updated_at", null: false
end
- add_foreign_key "character_to_stars", "characters"
- add_foreign_key "character_to_stars", "stars"
+ add_foreign_key "characters", "stars"
end
diff --git a/lib/tasks/db/construction.rake b/lib/tasks/db/construction.rake
index b36a626..bd6fbab 100644
--- a/lib/tasks/db/construction.rake
+++ b/lib/tasks/db/construction.rake
@@ -12,10 +12,6 @@ namespace :db do
end
end
- # 以下、CSVをもとにして本データベースを作成していく
- ImportService::Character.new.execute
- ImportService::Gss::Character.new.execute
-
output_erd if Rails.env.development?
end
end
diff --git a/lib/tasks/db/importer.rake b/lib/tasks/db/importer.rake
index 515d2ba..5e9f46f 100644
--- a/lib/tasks/db/importer.rake
+++ b/lib/tasks/db/importer.rake
@@ -1,19 +1,22 @@
namespace :db do
namespace :importer do
- desc 'インポータ(データソースのインポートはスコープ外)'
+ desc 'インポータ(OnSheet のデータを元に本テーブルへインポートする)'
task execute: :environment do
ActiveRecord::Base.transaction do
- show_message_and_execute_on_importer('Character')
- show_message_and_execute_on_importer('Star')
- end
- end
- end
-end
+ # 順番に意味はある
-def show_message_and_execute_on_importer(class_name_string)
- puts "[#{Time.zone.now}] #{class_name_string} の実行を開始します。"
+ puts "[#{Time.zone.now}] ImportService::Star の実行を開始します。"
+ ImportService::Star.new.execute
+ puts "[#{Time.zone.now}] ImportService::Star の実行が終了しました。"
- `bundle exec rails runner "ImportService::#{class_name_string}.new.execute"`
+ puts "[#{Time.zone.now}] ImportService::Character の実行を開始します。"
+ ImportService::Character.new.execute
+ puts "[#{Time.zone.now}] ImportService::Character の実行が終了しました。"
- puts "[#{Time.zone.now}] #{class_name_string} の実行が終了しました。"
+ puts "[#{Time.zone.now}] ImportService::Gss::Character の実行を開始します。"
+ ImportService::Gss::Character.new.execute
+ puts "[#{Time.zone.now}] ImportService::Gss::Character の実行が終了しました。"
+ end
+ end
+ end
end
diff --git a/spec/models/character_to_star_spec.rb b/spec/models/character_to_star_spec.rb
deleted file mode 100644
index 35ca963..0000000
--- a/spec/models/character_to_star_spec.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe CharacterToStar, type: :model do
- pending "add some examples to (or delete) #{__FILE__}"
-end
diff --git a/spec/service/import_service/on_sheet/star_spec.rb b/spec/service/import_service/on_sheet/star_spec.rb
index 58b2b36..8bec758 100644
--- a/spec/service/import_service/on_sheet/star_spec.rb
+++ b/spec/service/import_service/on_sheet/star_spec.rb
@@ -27,7 +27,7 @@
seating_order
category
name
- name_kana
+ yomi
name_en
]
end
@@ -46,7 +46,7 @@
seating_order
category
name
- name_kana
+ yomi
name_en
]
end