feat(chats): tags

This commit is contained in:
Daniel Kempkens 2023-08-21 00:20:42 +02:00
parent f443a5b7ae
commit b301a3a726
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
6 changed files with 43 additions and 13 deletions

1
.gitignore vendored
View file

@ -38,3 +38,4 @@ erl_crash.dump
/tags*
/xref_graph.dot
/xref_graph.png
/scripts

View file

@ -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";

View file

@ -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
)

25
mix.nix
View file

@ -1,4 +1,4 @@
{ lib, beamPackages, overrides ? (x: y: {}) }:
{ lib, beamPackages, overrides ? (x: y: { }) }:
let
buildRebar3 = lib.makeOverridable beamPackages.buildRebar3;
@ -44,7 +44,7 @@ let
sha256 = "1c4dgi8canscyjgddp22mjc69znvwy44wk3r7jrl2wvs6vv76fqn";
};
beamDeps = [];
beamDeps = [ ];
};
db_connection = buildMix rec {
@ -70,7 +70,7 @@ let
sha256 = "1k7z418b6cj977wswpxsk5844xrxc1smaiqsmrqpf3pdjzsfbksk";
};
beamDeps = [];
beamDeps = [ ];
};
earmark = buildMix rec {
@ -96,7 +96,7 @@ let
sha256 = "13qvlqnii8g6bcz6cl330vjwaan7jy30g1app3yvjncvf8rnhlid";
};
beamDeps = [];
beamDeps = [ ];
};
ecto = buildMix rec {
@ -135,7 +135,7 @@ let
sha256 = "1p0myxmnjjds8bbg69dd6fvhk8q3n7lb78zd4qvmjajnzgdmw6a1";
};
beamDeps = [];
beamDeps = [ ];
};
jason = buildMix rec {
@ -161,7 +161,7 @@ let
sha256 = "0p50h0ki8ay5sraiqxiajgwy1829bvyagj65bj9wjny4cnin83fs";
};
beamDeps = [];
beamDeps = [ ];
};
plug = buildMix rec {
@ -200,7 +200,7 @@ let
sha256 = "0hnqgzc3zas7j7wycgnkkdhaji5farkqccy2n4p1gqj5ccfrlm16";
};
beamDeps = [];
beamDeps = [ ];
};
postgrex = buildMix rec {
@ -226,7 +226,7 @@ let
sha256 = "1rfz5ld54pkd2w25jadyznia2vb7aw9bclck21fizargd39wzys9";
};
beamDeps = [];
beamDeps = [ ];
};
telemetry = buildRebar3 rec {
@ -239,7 +239,7 @@ let
sha256 = "1mgyx9zw92g6w8fp9pblm3b0bghwxwwcbslrixq23ipzisfwxnfs";
};
beamDeps = [];
beamDeps = [ ];
};
typed_struct = buildMix rec {
@ -252,7 +252,7 @@ let
sha256 = "0v8v3l8j7g3ran3f9gc2nc1mkj6kwfdr6kshm2cf3r0zlv1xa2y5";
};
beamDeps = [];
beamDeps = [ ];
};
yamerl = buildRebar3 rec {
@ -265,7 +265,7 @@ let
sha256 = "0vjf9gnchvh4qfykrxf0jw0didvfrx54wdm26z41s1gicclxnsil";
};
beamDeps = [];
beamDeps = [ ];
};
yaml_elixir = buildMix rec {
@ -281,5 +281,6 @@ let
beamDeps = [ yamerl ];
};
};
in self
in
self

View 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

View file

@ -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 %>