-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 🎸 g model Nickname * feat: 🎸 GssCharacterToNickname モデル(中間テーブル)を作成した * feat: 🎸 db:migrate * fix: 🐛 Gss::Character の name を sosenkyo_name から取得するように修正した * feat: 🎸 Nickname モデルのインポータ作成 * style: 💄 RuboCop の指摘に従い修正した * test: 💍 Spec を追加した
- Loading branch information
1 parent
b28bf24
commit 83d63b1
Showing
32 changed files
with
2,097 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class GssCharacterToNickname < ApplicationRecord | ||
belongs_to :gss_character, class_name: 'Gss::Character', foreign_key: :gss_character_id | ||
belongs_to :nickname, class_name: 'Nickname', foreign_key: :nickname_id | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Nickname < ApplicationRecord | ||
has_many :gss_character_to_nicknames, class_name: 'GssCharacterToNickname' | ||
has_many :gss_characters, through: :gss_character_to_nicknames, class_name: 'Gss::Character' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module OnSheet | ||
class Nickname < ApplicationRecord | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module ImportService | ||
class GssCharacterToNickname < Base | ||
def rows | ||
# columns | ||
# gss_character_id | ||
# nickname_id | ||
|
||
rows = [] | ||
nickname_records = ::OnSheet::Nickname.all | ||
|
||
nickname_records.each do |nickname_record| | ||
gss_character_name = nickname_record.name | ||
gss_character_id = ::Gss::Character.find_by(name: gss_character_name).id | ||
|
||
nicknames = [ | ||
nickname_record.nickname_01, | ||
nickname_record.nickname_02, | ||
nickname_record.nickname_03, | ||
nickname_record.nickname_04, | ||
nickname_record.nickname_05, | ||
nickname_record.nickname_06, | ||
nickname_record.nickname_07, | ||
nickname_record.nickname_08, | ||
nickname_record.nickname_09, | ||
nickname_record.nickname_10, | ||
nickname_record.nickname_11, | ||
nickname_record.nickname_12, | ||
nickname_record.nickname_13, | ||
].compact_blank | ||
|
||
nicknames.each do |nickname| | ||
next if nickname == gss_character_name | ||
|
||
nickname_id = ::Nickname.find_by(name: nickname).id | ||
|
||
rows << [ | ||
gss_character_id, | ||
nickname_id, | ||
] | ||
end | ||
end | ||
|
||
rows | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module ImportService | ||
class Nickname < Base | ||
def rows | ||
# columns | ||
# name | ||
|
||
nickname_records = ::OnSheet::Nickname.all | ||
|
||
nicknames = nickname_records.map do |nickname_record| | ||
[ | ||
nickname_record.nickname_01, | ||
nickname_record.nickname_02, | ||
nickname_record.nickname_03, | ||
nickname_record.nickname_04, | ||
nickname_record.nickname_05, | ||
nickname_record.nickname_06, | ||
nickname_record.nickname_07, | ||
nickname_record.nickname_08, | ||
nickname_record.nickname_09, | ||
nickname_record.nickname_10, | ||
nickname_record.nickname_11, | ||
nickname_record.nickname_12, | ||
nickname_record.nickname_13, | ||
].compact_blank | ||
end.flatten | ||
|
||
nicknames.uniq.map do |nickname| | ||
[ | ||
nickname, | ||
] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module ImportService | ||
module OnSheet | ||
class Nickname < Base | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.