only show tags which do not have the tag yet

This commit is contained in:
Inhji 2023-09-23 22:43:06 +02:00
parent 26bcc7d383
commit 71d57cafd1
2 changed files with 13 additions and 1 deletions

View File

@ -63,6 +63,7 @@ defmodule Chiya.Notes do
|> where([n], fragment("? ~ ?", n.name, ^tag.regex))
|> or_where([n], fragment("? ~ ?", n.url, ^tag.regex))
|> or_where([n], fragment("? ~ ?", n.content, ^tag.regex))
|> preload(^@preloads)
|> Repo.all()
end

View File

@ -15,7 +15,18 @@ defmodule ChiyaWeb.TagController do
def apply_prepare(conn, %{"id" => id}) do
tag = Tags.get_tag!(id)
notes = Chiya.Notes.list_apply_notes(tag)
notes =
tag
|> Chiya.Notes.list_apply_notes()
|> Enum.filter(fn note ->
exists =
note.tags
|> Enum.map(fn t -> t.name end)
|> Enum.member?(tag.name)
!exists
end)
render(conn, :apply_prepare, tag: tag, notes: notes)
end