From 7675e173d4d65892f4f8780883e0bd96c34f023d Mon Sep 17 00:00:00 2001 From: Raphael Maenle Date: Mon, 17 Jan 2022 15:33:59 +0100 Subject: [PATCH] database returns title of messages --- lib/bump/database.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/bump/database.ex b/lib/bump/database.ex index fd0d6fb..459b745 100644 --- a/lib/bump/database.ex +++ b/lib/bump/database.ex @@ -9,13 +9,13 @@ defmodule Bump.Database do where: m.sender == ^sender, order_by: [desc: m.timestamp], 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) if not is_nil(res) do 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 %{} end @@ -27,7 +27,7 @@ defmodule Bump.Database do where: m.sender == ^sender, order_by: [desc: m.timestamp], limit: 1, - select: %{data: m.data, timestamp: m.timestamp} + select: %{title: m.title, data: m.data, timestamp: m.timestamp} Repo.one(query) end @@ -40,7 +40,7 @@ defmodule Bump.Database do query = from m in "messages", where: m.sender == ^sender and m.timestamp >= ^ago, - select: %{data: m.data, timestamp: m.timestamp} + select: %{title: m.title, data: m.data, timestamp: m.timestamp} Repo.all(query) end