database returns title of messages
This commit is contained in:
parent
83975a0918
commit
7675e173d4
@ -9,13 +9,13 @@ defmodule Bump.Database do
|
|||||||
where: m.sender == ^sender,
|
where: m.sender == ^sender,
|
||||||
order_by: [desc: m.timestamp],
|
order_by: [desc: m.timestamp],
|
||||||
limit: 1,
|
limit: 1,
|
||||||
select: %{id: m.id, data: m.data, timestamp: m.timestamp}
|
select: %{id: m.id, title: m.title, data: m.data, timestamp: m.timestamp}
|
||||||
|
|
||||||
res = Repo.one(query)
|
res = Repo.one(query)
|
||||||
|
|
||||||
if not is_nil(res) do
|
if not is_nil(res) do
|
||||||
Repo.delete_all(from m in "messages", where: m.id == ^res.id)
|
Repo.delete_all(from m in "messages", where: m.id == ^res.id)
|
||||||
%{data: res.data, timestamp: res.timestamp}
|
%{title: res.title, data: res.data, timestamp: res.timestamp}
|
||||||
else
|
else
|
||||||
%{}
|
%{}
|
||||||
end
|
end
|
||||||
@ -27,7 +27,7 @@ defmodule Bump.Database do
|
|||||||
where: m.sender == ^sender,
|
where: m.sender == ^sender,
|
||||||
order_by: [desc: m.timestamp],
|
order_by: [desc: m.timestamp],
|
||||||
limit: 1,
|
limit: 1,
|
||||||
select: %{data: m.data, timestamp: m.timestamp}
|
select: %{title: m.title, data: m.data, timestamp: m.timestamp}
|
||||||
Repo.one(query)
|
Repo.one(query)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ defmodule Bump.Database do
|
|||||||
query = from m in "messages",
|
query = from m in "messages",
|
||||||
where: m.sender == ^sender and
|
where: m.sender == ^sender and
|
||||||
m.timestamp >= ^ago,
|
m.timestamp >= ^ago,
|
||||||
select: %{data: m.data, timestamp: m.timestamp}
|
select: %{title: m.title, data: m.data, timestamp: m.timestamp}
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user