スキルパネル作成
alias Bright.{Repo, SkillPanels, SkillUnits}
Create SkillPanel with SkillClass
{:ok, skill_panel} =
SkillPanels.create_skill_panel(%{
name: "Webアプリ開発 Elixir",
skill_classes: [
%{name: "零細Webアプリ開発がこなせる", class: 1},
%{name: "小規模Webアプリ開発、マイクロサービス構築がこなせる", class: 2}
]
})
Create SkillUnit with SkillCategory and Skill
[skill_class1, skill_class2 | _] = skill_panel.skill_classes
{skill_class1.name, skill_class2.name}
{:ok, skill_unit} =
SkillUnits.create_skill_unit(%{
name: "Elixir本体",
skill_categories: [
%{
name: "基本",
position: 1,
skills: [
%{name: "基本型/演算子/制御構文/パイプ", position: 1},
%{name: "config追加/変更", position: 2}
]
},
%{
name: "データ処理(ループ制御相当)",
position: 2,
skills: [
%{name: "Enum.map", position: 1},
%{name: "Enum.reduce", position: 2}
]
}
],
skill_class_units: [
%{skill_class_id: skill_class1.id, position: 1},
%{skill_class_id: skill_class2.id, position: 2}
]
})
Get SkillUnit and preload associations with correct order
[skill_unit | _] =
SkillUnits.list_skill_units()
|> Repo.preload(:skill_classes, skill_categories: :skills)
skill_unit.skill_classes
SkillUnits.delete_skill_unit(skill_unit)