28 lines
517 B
Elixir
28 lines
517 B
Elixir
|
defmodule Bump.Messages do
|
||
|
alias Bump.Repo
|
||
|
import Ecto.Query
|
||
|
|
||
|
def get_newest_message(_sender) do
|
||
|
end
|
||
|
|
||
|
def get_all_messages_since(sender, minutes) do
|
||
|
|
||
|
ago = DateTime.utc_now
|
||
|
|> Timex.shift(minutes: -minutes)
|
||
|
|> DateTime.truncate(:second)
|
||
|
|
||
|
query = from m in "messages",
|
||
|
where: m.sender == ^sender and
|
||
|
m.timestamp >= ^ago,
|
||
|
select: m.data
|
||
|
Repo.all(query)
|
||
|
end
|
||
|
|
||
|
def remove_sender(_sender) do
|
||
|
end
|
||
|
|
||
|
def add_message(_sender, _message) do
|
||
|
end
|
||
|
|
||
|
end
|