Skip to content

Commit

Permalink
remove people schema/table from project! #118
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Aug 5, 2022
1 parent c231b71 commit 316929c
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 787 deletions.
661 changes: 39 additions & 622 deletions README.md

Large diffs are not rendered by default.

74 changes: 0 additions & 74 deletions lib/app/person.ex

This file was deleted.

3 changes: 1 addition & 2 deletions lib/app/timer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule App.Timer do

schema "timers" do
field :item_id, :id
field :person_id, :id
field :start, :naive_datetime
field :stop, :naive_datetime

Expand All @@ -18,7 +17,7 @@ defmodule App.Timer do
@doc false
def changeset(timer, attrs) do
timer
|> cast(attrs, [:item_id, :person_id, :start, :stop])
|> cast(attrs, [:item_id, :start, :stop])
|> validate_required([:item_id, :start])
end

Expand Down
3 changes: 0 additions & 3 deletions lib/app_web/controllers/auth_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ defmodule AppWeb.AuthController do
|> AuthPlug.Helpers.strip_struct_metadata()
|> Useful.atomize_map_keys()

IO.inspect(claims, label: "claims")
App.Person.upsert(claims)

socket =
socket
|> assign_new(:person, fn -> claims end)
Expand Down
16 changes: 0 additions & 16 deletions priv/repo/migrations/20220627162148_create_people.exs

This file was deleted.

2 changes: 1 addition & 1 deletion priv/repo/migrations/20220627162154_create_items.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule App.Repo.Migrations.CreateItems do
def change do
create table(:items) do
add(:text, :string)
add(:person_id, references(:people, on_delete: :nothing))
add(:person_id, :integer)
add(:status, :integer)

timestamps()
Expand Down
2 changes: 0 additions & 2 deletions priv/repo/migrations/20220627162209_create_timers.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ defmodule App.Repo.Migrations.CreateTimers do
add :start, :naive_datetime
add :stop, :naive_datetime
add :item_id, references(:items, on_delete: :nothing)
add :person_id, references(:people, on_delete: :nothing)

timestamps()
end

create index(:timers, [:item_id])
create index(:timers, [:person_id])
end
end
20 changes: 0 additions & 20 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
if not Envar.is_set?("AUTH_API_KEY") do
Envar.load(".env")
end

# Create the default person
App.Person.upsert(
%{
givenName: "guest",
auth_provider: "none",
status: 2, # no association just an int
id: 0 # stackoverflow.com/questions/32728179/primary-key-postgres-zero
}
)
# |> IO.inspect(label: "default person")

App.Person.upsert(
%{
givenName: "Admin",
auth_provider: "google",
status: 1,
id: 1
}
)
41 changes: 0 additions & 41 deletions test/app/person_test.exs

This file was deleted.

7 changes: 1 addition & 6 deletions test/app_web/live/app_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule AppWeb.AppLiveTest do

started = NaiveDateTime.utc_now()
{:ok, _timer} =
Timer.start(%{item_id: item.id, person_id: 1, start: started})
Timer.start(%{item_id: item.id, start: started})

# See: https://github.com/dwyl/useful/issues/17#issuecomment-1186070198
# assert Useful.typeof(:timer_id) == "atom"
Expand Down Expand Up @@ -189,9 +189,4 @@ defmodule AppWeb.AppLiveTest do
conn = get(conn, "/login")
assert redirected_to(conn, 302) =~ "auth.dwyl.com"
end

# test "test clicking logout button fires handle_event :logout", %{conn: conn} do
# conn = get(conn, "/login")
# assert redirected_to(conn, 302) =~ "auth.dwyl.com"
# end
end

0 comments on commit 316929c

Please sign in to comment.