From 0919792d534fd415adf94e280ffede54342254d9 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Tue, 10 Dec 2019 20:21:37 -0500 Subject: [PATCH] actually filter the tags --- lib/philomena_web/controllers/profile_controller.ex | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/philomena_web/controllers/profile_controller.ex b/lib/philomena_web/controllers/profile_controller.ex index bba35831..8bb5df4e 100644 --- a/lib/philomena_web/controllers/profile_controller.ex +++ b/lib/philomena_web/controllers/profile_controller.ex @@ -37,9 +37,15 @@ defmodule PhilomenaWeb.ProfileController do ) tags = tags(conn.assigns.user.public_links) + + all_tag_ids = + conn.assigns.user.verified_links + |> tags() + |> Enum.map(& &1.id) watcher_counts = Tag + |> where([t], t.id in ^all_tag_ids) |> join(:inner_lateral, [t], _ in fragment("SELECT count(*) FROM users WHERE watched_tag_ids @> ARRAY[?]", t.id)) |> select([t, c], {t.id, c.count}) |> Repo.all()