add tag_count to supported clientside fields (fixes philomena-dev/philomena#78)

This commit is contained in:
byte[] 2020-12-02 18:31:15 -05:00
parent d8f04fe922
commit aaf04544b6
2 changed files with 4 additions and 1 deletions

View file

@ -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',

View file

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