database returns title of messages
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user