[Posts] Add contributor category (#794)

This commit is contained in:
Donovan Daniels 2024-12-18 08:07:30 -06:00 committed by GitHub
parent 32a1367cfe
commit b44f8a7d6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 79 additions and 35 deletions

View File

@ -28,6 +28,7 @@ module PostIndex
tag_count_general: { type: "integer" },
tag_count_artist: { type: "integer" },
tag_count_contributor: { type: "integer" },
tag_count_character: { type: "integer" },
tag_count_copyright: { type: "integer" },
tag_count_meta: { type: "integer" },
@ -237,14 +238,15 @@ module PostIndex
tag_count_general: tag_count_general,
tag_count_artist: tag_count_artist,
tag_count_contributor: tag_count_contributor,
tag_count_character: tag_count_character,
tag_count_copyright: tag_count_copyright,
tag_count_meta: tag_count_meta,
tag_count_species: tag_count_species,
tag_count_invalid: tag_count_invalid,
tag_count_lore: tag_count_lore,
comment_count: options[:comment_count] || comment_count,
comment_count: options[:comment_count] || comment_count,
file_size: file_size,
parent: parent_id,
pools: options[:pools] || ::Pool.where("? = ANY(post_ids)", id).pluck(:id),

View File

@ -11,6 +11,7 @@
Related:
<a href="#" @click.prevent="findRelated()">Tags</a> |
<a href="#" @click.prevent="findRelated(1)">Artists</a> |
<a href="#" @click.prevent="findRelated(2)">Contributors</a> |
<a href="#" @click.prevent="findRelated(3)">Copyrights</a> |
<a href="#" @click.prevent="findRelated(4)">Characters</a> |
<a href="#" @click.prevent="findRelated(5)">Species</a> |

View File

@ -28,7 +28,7 @@
<template v-if="normalMode">
<div class="flex-grid border-bottom">
<div class="col">
<label class="section-label" for="names">Artists</label>
<label class="section-label" for="names">Artists and Contributors</label>
<div><a href="/forum_topics/23553">How do I tag an artist?</a></div>
<div>Please don't use <a href="/wiki_pages/anonymous_artist">anonymous_artist</a> or <a href="/wiki_pages/unknown_artist">unknown_artist</a> tags unless they fall under those definitions on the wiki.</div>
</div>

View File

@ -156,6 +156,7 @@ $user-home-greeting-color: gold;
$tag-categories: (
"0": "general",
"1": "artist",
"2": "contributor",
"3": "copyright",
"4": "character",
"5": "species",
@ -167,6 +168,7 @@ $tag-categories: (
$tag-categories-short: (
"gen": "general",
"art": "artist",
"cont": "contributor",
"copy": "copyright",
"char": "character",
"spec": "species",

View File

@ -83,6 +83,9 @@ body {
--color-tag-artist: #f2ac08;
--color-tag-artist-alt: #fbd67f;
--color-tag-contributor: #c0c0c0;
--color-tag-contributor-alt: #71706e;
--color-tag-copyright: #d0d;
--color-tag-copyright-alt: #ff5eff;

View File

@ -6,6 +6,9 @@ class TagCategory
"gen" => 0,
"artist" => 1,
"art" => 1,
"contributor" => 2,
"contrib" => 2,
"cont" => 2,
"copyright" => 3,
"copy" => 3,
"co" => 3,
@ -25,6 +28,7 @@ class TagCategory
CANONICAL_MAPPING = {
"General" => 0,
"Artist" => 1,
"Contributor" => 2,
"Copyright" => 3,
"Character" => 4,
"Species" => 5,
@ -36,6 +40,7 @@ class TagCategory
REVERSE_MAPPING = {
0 => "general",
1 => "artist",
2 => "contributor",
3 => "copyright",
4 => "character",
5 => "species",
@ -47,6 +52,7 @@ class TagCategory
SHORT_NAME_MAPPING = {
"gen" => "general",
"art" => "artist",
"cont" => "contributor",
"copy" => "copyright",
"char" => "character",
"spec" => "species",
@ -58,6 +64,7 @@ class TagCategory
HEADER_MAPPING = {
"general" => "General",
"artist" => "Artists",
"contributor" => "Contributors",
"copyright" => "Copyrights",
"character" => "Characters",
"species" => "Species",
@ -69,6 +76,7 @@ class TagCategory
ADMIN_ONLY_MAPPING = {
"general" => false,
"artist" => false,
"contributor" => false,
"copyright" => false,
"character" => false,
"species" => false,
@ -98,13 +106,13 @@ class TagCategory
},
}.freeze
CATEGORIES = %w[general species character copyright artist invalid lore meta].freeze
CATEGORIES = %w[general species character copyright artist contributor invalid lore meta].freeze
CATEGORY_IDS = CANONICAL_MAPPING.values
SHORT_NAME_LIST = SHORT_NAME_MAPPING.keys
HUMANIZED_LIST = %w[character copyright artist].freeze
SPLIT_HEADER_LIST = %w[invalid artist copyright character species general meta lore].freeze
CATEGORIZED_LIST = %w[invalid artist copyright character species meta general lore].freeze
SPLIT_HEADER_LIST = %w[invalid artist contributor copyright character species general meta lore].freeze
CATEGORIZED_LIST = %w[invalid artist contributor copyright character species meta general lore].freeze
SHORT_NAME_REGEX = SHORT_NAME_LIST.join("|").freeze
ALL_NAMES_REGEX = MAPPING.keys.join("|").freeze

View File

@ -87,6 +87,7 @@
["Tag count", "total_tags"],
["General tag count", "general_tags", "total_tags"],
["Artist tag count", "artist_tags", "total_tags"],
["Contributor tag count", "contributor_tags", "total_tags"],
["Character tag count", "character_tags", "total_tags"],
["Copyright tag count", "copyright_tags", "total_tags"],
["Species tag count", "species_tags", "total_tags"],

View File

@ -0,0 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config", "environment"))
client = Post.document_store.client
client.indices.put_mapping(index: Post.document_store.index_name, body: { properties: { tag_count_contributor: { type: "integer" } } })

View File

@ -0,0 +1,9 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "config", "environment"))
client = Post.document_store.client
Post.find_in_batches(batch_size: 10_000) do |posts|
client.bulk(body: posts.map { |post| { update: { _index: Post.document_store.index_name, _id: post.id, data: { doc: { tag_count_contributor: 0 } } } } }, refresh: true)
end

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
class AddContributorCategory < ActiveRecord::Migration[7.1]
def change
Post.without_timeout do
add_column(:posts, :tag_count_contributor, :integer, default: 0, null: false)
end
end
end

View File

@ -1686,7 +1686,8 @@ CREATE TABLE public.posts (
generated_samples character varying[],
duration numeric,
is_comment_disabled boolean DEFAULT false NOT NULL,
is_comment_locked boolean DEFAULT false NOT NULL
is_comment_locked boolean DEFAULT false NOT NULL,
tag_count_contributor integer DEFAULT 0 NOT NULL
);
@ -4677,6 +4678,7 @@ ALTER TABLE ONLY public.avoid_postings
SET search_path TO "$user", public;
INSERT INTO "schema_migrations" (version) VALUES
('20241114055212'),
('20240905160626'),
('20240726170041'),
('20240709134926'),