このコミットが含まれているのは:
2026-10-27 01:11:13 +09:00
コミット 30b5fe5f05
17個のファイルの変更、766行の追加、168行の削除
+22 -4
ファイルの表示
@@ -61,6 +61,10 @@ export type CountsPivotHeader = { values: (string | number | null)[]
kind: 'data' | 'subtotal' | 'grand_total' }
export type CountsResult = {
populationCount?: number
excludedCount?: number
outputCount?: number | null
visibleOutputCount?: number
outputCountScope?: 'before_authorisation' | 'unavailable_private_history'
populationCountScope?: string
rowHeaders?: CountsPivotHeader[]
columnHeaders?: CountsPivotHeader[]
@@ -148,7 +152,7 @@ const nested: Partial<Record<CountColumn, CountField[]>> = {
export const columnsForCounts = (
resource: CountsResource,
definition?: CountsDefinition,
): CountColumn[] => [
): CountColumn[] => definition?.outputFields?.map (field => field.key) ?? [
...(resource === 'posts' ? ['thumbnail'] : []),
'resource_id', 'version_no', 'is_latest',
...(resource === 'posts'
@@ -165,7 +169,8 @@ export const columnsForCounts = (
export const fieldsForCounts = (
resource: CountsResource,
definition?: CountsDefinition,
): CountField[] => columnsForCounts (resource, definition).map (key => ({
): CountField[] => definition?.outputFields
?? columnsForCounts (resource, definition).map (key => ({
key,
label: (key === 'parents' && resource === 'tags') ? 'tags:parents'
: (countColumns[key] ?? countsFieldLabel (key)),
@@ -303,6 +308,17 @@ export const defaultCountsMode = (definition: string | null): 'summary' | 'detai
definition === 'history' ? 'details' : 'summary'
export const countsDefinitionParams = (
definition: 'latest' | 'history',
previous: URLSearchParams,
): URLSearchParams => {
const next = new URLSearchParams ({ definition, mode: defaultCountsMode (definition) })
for (const key of ['timezone', 'row_numbers'])
if (previous.has (key)) next.set (key, previous.get (key)!)
return next
}
export const normaliseCountsParams = (
resource: CountsResource,
source: URLSearchParams,
@@ -311,7 +327,8 @@ export const normaliseCountsParams = (
const params = new URLSearchParams (source)
if (!params.has ('definition'))
params.set ('definition', params.get ('basis') === 'history' ? 'history' : 'latest')
if (!params.has ('current')) params.set ('current', params.get ('at') ? '0' : '1')
if (params.get ('definition') === 'latest' && !params.has ('current'))
params.set ('current', params.get ('at') ? '0' : '1')
const legacy = params.get ('mode')
if (['state', 'trend', 'snapshot'].includes (legacy ?? ''))
params.set ('mode', legacy === 'snapshot' ? 'details' : 'summary')
@@ -392,8 +409,9 @@ export const fetchCounts = (
resource: CountsResource,
params: URLSearchParams,
locale: LocaleCode,
signal?: AbortSignal,
): Promise<CountsResult> => apiGet ('/counts/query', {
locale, params: { ...Object.fromEntries (countsRequestParams (params)), resource } })
locale, signal, params: { ...Object.fromEntries (countsRequestParams (params)), resource } })