Skip to content

Context with schema for Events CRUD#27

Open
Menubatenny wants to merge 7 commits intomainfrom
events
Open

Context with schema for Events CRUD#27
Menubatenny wants to merge 7 commits intomainfrom
events

Conversation

@Menubatenny
Copy link
Contributor

closes #9

render(conn, "new.html", changeset: changeset)
end

def create(conn, %{"event" => event_params}) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a service module for events.
Events will have more things to implement, and those things can't be part of controller. Let's extract these code to a svc module and use context inside it

@sreecodeslayer sreecodeslayer changed the title Context with schema for CRUD Context with schema for Events CRUD Sep 13, 2021
Comment on lines +8 to +9
field :end_date, :string
field :start_date, :string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two should be utc datetime type, not strings

{:ok, event} ->
conn
|> put_flash(:info, "Site created successfully.")
|> redirect(to: Routes.site_event_path(conn, :index, :id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redirect(to: Routes.site_event_path(conn, :index, :id))

Will this line work? Shouldn't we be passing the id of the site?

Comment on lines +44 to +47
site_id = Nudge.Accounts.get_site!(id)

IO.inspect(site_id)
events = Sites.list_site_events(site_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does get_site!/1 return just id or the whole site struct with data?

This is why we end up having type casting error in the query. The query expects and id, but you are passing the whole result to the list_site_events/1

Comment on lines +25 to +28
query =
from site in Nudge.Accounts.Site,
where: site.id == ^site_id,
order_by: site.inserted_at
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right query for filtering events?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Events] Context with schema for CRUD

2 participants