built basic ui structure in /hierarchy
This commit is contained in:
@@ -1,11 +1,73 @@
|
||||
# Script for populating the database. You can run it as:
|
||||
#
|
||||
# mix run priv/repo/seeds.exs
|
||||
#
|
||||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# RiverConnect.Repo.insert!(%RiverConnect.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
actions = [
|
||||
fn ->
|
||||
alias RiverConnect.Hierarchy
|
||||
alias RiverConnect.Repo
|
||||
|
||||
# 1. Create DM Spring
|
||||
case Repo.get_by(Hierarchy.Spring, name: "Direct Messages") do
|
||||
nil ->
|
||||
{:ok, spring} =
|
||||
Hierarchy.create_spring(%{
|
||||
name: "Direct Messages",
|
||||
type: "dm",
|
||||
description: "Private conversations between users"
|
||||
})
|
||||
|
||||
IO.puts("Created 'Direct Messages' Spring")
|
||||
spring
|
||||
|
||||
spring ->
|
||||
IO.puts("'Direct Messages' Spring already exists")
|
||||
spring
|
||||
end
|
||||
|
||||
# 2. Create Jobs Spring
|
||||
{:ok, jobs_spring} =
|
||||
case Repo.get_by(Hierarchy.Spring, name: "Jobs") do
|
||||
nil ->
|
||||
{:ok, spring} =
|
||||
Hierarchy.create_spring(%{
|
||||
name: "Jobs",
|
||||
type: "job",
|
||||
description: "Job-specific rivers"
|
||||
})
|
||||
|
||||
IO.puts("Created 'Jobs' Spring")
|
||||
{:ok, spring}
|
||||
|
||||
spring ->
|
||||
IO.puts("'Jobs' Spring already exists")
|
||||
{:ok, spring}
|
||||
end
|
||||
|
||||
# 3. Create a sample River in Jobs
|
||||
case Repo.get_by(Hierarchy.River, name: "General Construction", spring_id: jobs_spring.id) do
|
||||
nil ->
|
||||
{:ok, river} =
|
||||
Hierarchy.create_river(%{
|
||||
name: "General Construction",
|
||||
description: "General discussions about construction jobs",
|
||||
spring_id: jobs_spring.id
|
||||
})
|
||||
|
||||
IO.puts("Created 'General Construction' River")
|
||||
|
||||
# 4. Create sample Stream
|
||||
{:ok, _stream} =
|
||||
Hierarchy.create_stream(%{
|
||||
name: "Announcements",
|
||||
topic: "Important announcements",
|
||||
river_id: river.id
|
||||
})
|
||||
|
||||
IO.puts("Created 'Announcements' Stream")
|
||||
|
||||
_ ->
|
||||
IO.puts("'General Construction' River already exists")
|
||||
end
|
||||
end
|
||||
]
|
||||
|
||||
for action <- actions do
|
||||
action.()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user