saving shifts working

This commit is contained in:
Adam Piontek 2021-03-16 11:00:33 -04:00
parent 4276399c20
commit ecd4d83e3f
9 changed files with 141 additions and 67 deletions
lib/shift73k

View file

@ -21,6 +21,16 @@ defmodule Shift73k.Shifts do
Repo.all(Shift)
end
def list_shifts_by_user_between_dates(user_id, start_date, end_date) do
q = from(
s in Shift,
select: %{date: s.date, subject: s.subject, time_start: s.time_start, time_end: s.time_end},
where: s.user_id == ^user_id and s.date >= ^start_date and s.date < ^end_date,
order_by: [s.date, s.time_start]
)
Repo.all(q)
end
@doc """
Gets a single shift.

View file

@ -22,7 +22,7 @@ defmodule Shift73k.Shifts.Templates do
end
def list_shift_templates_by_user_id(user_id) do
q = from s in ShiftTemplate, where: s.user_id == ^user_id, order_by: s.subject
q = from s in ShiftTemplate, where: s.user_id == ^user_id, order_by: [s.subject, s.time_start]
Repo.all(q)
end