feat(chats): tags
This commit is contained in:
parent
f443a5b7ae
commit
b301a3a726
6 changed files with 43 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -38,3 +38,4 @@ erl_crash.dump
|
|||
/tags*
|
||||
/xref_graph.dot
|
||||
/xref_graph.png
|
||||
/scripts
|
||||
|
|
|
@ -98,6 +98,9 @@
|
|||
erlang
|
||||
elixir
|
||||
postgres
|
||||
|
||||
pkgs.ruby_3_2
|
||||
pkgs.rubyPackages_3_2.nokogiri
|
||||
] ++ lib.optionals isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
|
||||
CoreFoundation
|
||||
CoreServices
|
||||
|
@ -138,6 +141,7 @@
|
|||
settings = {
|
||||
environment = {
|
||||
BDFR_BROWSER_BASE_DIRECTORY = "/Volumes/MediaScraper/Reddit";
|
||||
BDFR_BROWSER_CONFIG_FILE = "./priv/config.yml";
|
||||
BDFR_BROWSER_REPO_USER = db-user;
|
||||
BDFR_BROWSER_REPO_HOST = db-host;
|
||||
RELEASE_DISTRIBUTION = "none";
|
||||
|
|
|
@ -9,6 +9,7 @@ defmodule BdfrBrowser.Chat do
|
|||
|
||||
schema "chats" do
|
||||
field :accounts, {:array, :string}
|
||||
field :tags, {:array, :string}, default: []
|
||||
|
||||
has_many :messages, Message
|
||||
end
|
||||
|
@ -16,7 +17,13 @@ defmodule BdfrBrowser.Chat do
|
|||
def listing do
|
||||
from(c in __MODULE__,
|
||||
left_join: m in assoc(c, :messages),
|
||||
select: %{id: c.id, accounts: c.accounts, num_messages: count(m.id), latest_message: max(m.posted_at)},
|
||||
select: %{
|
||||
id: c.id,
|
||||
accounts: c.accounts,
|
||||
num_messages: count(m.id),
|
||||
latest_message: max(m.posted_at),
|
||||
tags: c.tags
|
||||
},
|
||||
order_by: [desc: max(m.posted_at)],
|
||||
group_by: c.id
|
||||
)
|
||||
|
|
3
mix.nix
3
mix.nix
|
@ -281,5 +281,6 @@ let
|
|||
beamDeps = [ yamerl ];
|
||||
};
|
||||
};
|
||||
in self
|
||||
in
|
||||
self
|
||||
|
||||
|
|
9
priv/repo/migrations/20230820220618_add_chat_tags.exs
Normal file
9
priv/repo/migrations/20230820220618_add_chat_tags.exs
Normal file
|
@ -0,0 +1,9 @@
|
|||
defmodule BdfrBrowser.Repo.Migrations.AddChatTags do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table("chats") do
|
||||
add :tags, {:array, :string}, default: []
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,6 +9,14 @@
|
|||
<h6 class="card-subtitle mb-2 text-body-secondary">
|
||||
<%= chat.num_messages %> message(s) - <%= DateTime.to_iso8601(chat.latest_message) %>
|
||||
</h6>
|
||||
|
||||
<%= if length(chat.tags) > 0 do %>
|
||||
<p>
|
||||
<%= for tag <- chat.tags do %>
|
||||
<span class="badge text-bg-info"><%= tag %></span>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
Reference in a new issue