このコミットが含まれているのは:
@@ -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 } })
|
||||
|
||||
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする