27 lines
723 B
Plaintext
27 lines
723 B
Plaintext
import { computeDateRange } from './dateRange.uts'
|
|
import { rpcOrEmptyArray } from './rpc.uts'
|
|
|
|
export type DeliveryAnalysisData = {
|
|
trendList: Array<UTSJSONObject>
|
|
topList: Array<UTSJSONObject>
|
|
startIso: string
|
|
endIso: string
|
|
}
|
|
|
|
export async function fetchDeliveryAnalysis(period: string): Promise<DeliveryAnalysisData> {
|
|
const { startIso, endIso } = computeDateRange(period)
|
|
|
|
const trendList = await rpcOrEmptyArray('rpc_delivery_efficiency_daily', {
|
|
p_start: startIso,
|
|
p_end: endIso
|
|
} as any)
|
|
|
|
const topList = await rpcOrEmptyArray('rpc_delivery_efficiency_top_drivers', {
|
|
p_start: startIso,
|
|
p_end: endIso,
|
|
p_limit: 10
|
|
} as any)
|
|
|
|
return { trendList, topList, startIso, endIso }
|
|
}
|