39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { DB } from "../../types/db"
|
|
import { managePb404 } from "../../utils/pbTools"
|
|
import pbClient from "../pbClient"
|
|
|
|
/**
|
|
* 根据给定的周来检索完整的统计信息。
|
|
* @param week - 需要检索统计信息的周。
|
|
* @returns 一个解析为指定周的完整统计信息的promise。
|
|
*/
|
|
const getFullStatisticsByWeek = (week: string) => {
|
|
return managePb404<DB.StatisticsPerWeek>(
|
|
async () =>
|
|
await pbClient
|
|
.collection("statisticsPerWeek")
|
|
.getFirstListItem(`week="${week}"`)
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 根据给定的周来检索项目统计信息。
|
|
* @param week - 需要检索统计信息的周。
|
|
* @returns 一个解析为指定周的项目统计信息数组的promise。
|
|
*/
|
|
const getProjStatisticsByWeek = (week: string) => {
|
|
return managePb404<DB.StatisticsPerProj[]>(
|
|
async () =>
|
|
await pbClient
|
|
.collection("statisticsPerProj")
|
|
.getFullList({ filter: `week="${week}"` })
|
|
)
|
|
}
|
|
|
|
const view = {
|
|
getFullStatisticsByWeek,
|
|
getProjStatisticsByWeek,
|
|
}
|
|
|
|
export default view
|