From aaf04544b6f5f2ba3320f7827b1f6c7b2ab6df1b Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Wed, 2 Dec 2020 18:31:15 -0500 Subject: [PATCH] add tag_count to supported clientside fields (fixes philomena-dev/philomena#78) --- assets/js/match_query.js | 3 ++- lib/philomena_web/views/image_view.ex | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/js/match_query.js b/assets/js/match_query.js index b8a790af..ae9a87ae 100644 --- a/assets/js/match_query.js +++ b/assets/js/match_query.js @@ -20,7 +20,7 @@ const tokenList = [ ], numberFields = ['id', 'width', 'height', 'aspect_ratio', 'comment_count', 'score', 'upvotes', 'downvotes', - 'faves'], + 'faves', 'tag_count'], dateFields = ['created_at'], literalFields = ['tags', 'orig_sha512_hash', 'sha512_hash', 'score', 'uploader', 'source_url', 'description'], @@ -37,6 +37,7 @@ const tokenList = [ height: 'data-height', aspect_ratio: 'data-aspect-ratio', comment_count: 'data-comment-count', + tag_count: 'data-tag-count', source_url: 'data-source-url', faves: 'data-faves', sha512_hash: 'data-sha512', diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index 0295dbd4..9015ce55 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -128,6 +128,7 @@ defmodule PhilomenaWeb.ImageView do image_id: image.id, image_tags: Jason.encode!(Enum.map(image.tags, & &1.id)), image_tag_aliases: image.tag_list_plus_alias_cache, + tag_count: length(image.tags), score: image.score, faves: image.faves_count, upvotes: image.upvotes_count, @@ -220,6 +221,7 @@ defmodule PhilomenaWeb.ImageView do %{ id: image.id, "namespaced_tags.name": String.split(image.tag_list_plus_alias_cache || "", ", "), + tag_count: length(image.tags), score: image.score, faves: image.faves_count, upvotes: image.upvotes_count,