diff --git a/backend/app/services/counts_population.rb b/backend/app/services/counts_population.rb index 6c7e4cb..986895d 100644 --- a/backend/app/services/counts_population.rb +++ b/backend/app/services/counts_population.rb @@ -198,7 +198,10 @@ class CountsPopulation raw = params['tags'] tokens = raw.split.reject { _1.downcase == 'type:or' } refs = PostTagSearch.parse_references(params, tokens, partial: true) - literals = PostTagSearch.literals(nil, tokens.join(' '), references: refs) + locale = Locale.find_by(code: params.fetch('locale', 'ja')) + raise ArgumentError unless locale + + literals = PostTagSearch.literals(locale, tokens.join(' '), references: refs) predicates = literals.map do |literal| reference = literal[:reference] expression = if reference diff --git a/backend/app/services/counts_table_query.rb b/backend/app/services/counts_table_query.rb index ceb29fe..40acc1e 100644 --- a/backend/app/services/counts_table_query.rb +++ b/backend/app/services/counts_table_query.rb @@ -434,7 +434,7 @@ class CountsTableQuery bound = @connection.quote(point) if population.history && @definition.resource == 'posts' key = kind == 'internal' ? 'tag_id' : 'external_tag_id' - pairs = population.scope.except(:select, :order).joins( + pairs = HistoryAccess.visible(population.scope, 'v').except(:select, :order).joins( "JOIN JSON_TABLE(v.tags_json, '$[*]' COLUMNS (tag_id BIGINT PATH '$.#{ key }', " + "version_no INT PATH '$.version_no' NULL ON EMPTY)) recorded_tag") .where('recorded_tag.tag_id IN (?)', ids).group('recorded_tag.tag_id') diff --git a/frontend/src/components/counts/CountsControls.tsx b/frontend/src/components/counts/CountsControls.tsx index ab4c58c..5a9a3c1 100644 --- a/frontend/src/components/counts/CountsControls.tsx +++ b/frontend/src/components/counts/CountsControls.tsx @@ -9,7 +9,7 @@ import FormField from '@/components/common/FormField' import HelpPopover from '@/components/common/HelpPopover' import TagInput from '@/components/common/TagInput' import { Button } from '@/components/ui/button' -import { countsUseLatest, fieldsForCounts, normaliseCountsParams, readCountSort, +import { countsRequestParams, countsUseLatest, fieldsForCounts, normaliseCountsParams, readCountSort, selectedCountChildren, selectedCountColumns } from '@/lib/counts' import { countsNestedIsScalar } from '@/lib/countsDisplay' import { useCountsDefinition } from '@/lib/countsDefinitions' @@ -26,9 +26,11 @@ import type { CountsResource, CountsResult } from '@/lib/counts' const CountsControls = ( { resource, applied, open, setOpen, execute, displayJSON, displayRowNumbers, - displayThumbnail, reorder, actions, conditionLabels, pending = false }: { + displayThumbnail, reorder, actions, conditionLabels, conditionLabelsParams, + pending = false }: { resource: CountsResource; applied: URLSearchParams; open: boolean conditionLabels?: CountsResult['conditionLabels'] + conditionLabelsParams?: string pending?: boolean setOpen: (open: boolean) => void execute: (params: URLSearchParams) => void @@ -42,6 +44,8 @@ const CountsControls = ( const id = useId () const motion = useClientMotion () const [draft, setDraft] = useState (() => new URLSearchParams (applied)) + const labelParams = conditionLabelsParams == null + ? null : new URLSearchParams (conditionLabelsParams) const thumbnail = selectedCountColumns (resource, applied, definition).includes ('thumbnail') const previousApplied = useRef ({ resource, params: new URLSearchParams (applied) }) const appliedState = applied.toString () @@ -282,7 +286,12 @@ const CountsControls = ( } } + conditionLabels={(labelParams != null + && draft.get ('current') === labelParams.get ('current') + && draft.get ('at') === labelParams.get ('at') + && countsRequestParams (draft).toString () + === countsRequestParams (labelParams).toString ()) + ? conditionLabels : undefined}/> diff --git a/frontend/src/lib/countsDisplay.ts b/frontend/src/lib/countsDisplay.ts index 20174a3..235dad6 100644 --- a/frontend/src/lib/countsDisplay.ts +++ b/frontend/src/lib/countsDisplay.ts @@ -454,8 +454,14 @@ export const countsConditionValue = ( return translateUIMessage ('bot', 'counts', locale).text if (value == null) return 'NULL' if (axis.field === 'tags' || axis.field === 'user') - return labels?.[axis.field]?.[String (value)] + { + if (labels == null) return '…' + const names = labels[axis.field] + if (names == null || !Object.prototype.hasOwnProperty.call (names, String (value))) + return '—' + return names[String (value)] || translateUIMessage ('notRegistered', 'counts', locale).text + } if (axis.field === 'changed_field') return translateUIMessage (countsFieldLabel (String (value)), 'counts', locale).text if (typeof value === 'boolean') diff --git a/frontend/src/pages/CountsResourcePage.tsx b/frontend/src/pages/CountsResourcePage.tsx index c901591..509c3dd 100644 --- a/frontend/src/pages/CountsResourcePage.tsx +++ b/frontend/src/pages/CountsResourcePage.tsx @@ -342,7 +342,9 @@ const CountsResourceContent = (
{definition != null && update ('order', value)}