|
|
|
@ -10,11 +10,16 @@ import ncMetaAclMw from '../../helpers/ncMetaAclMw';
|
|
|
|
|
import { getViewAndModelFromRequestByAliasOrId } from './helpers'; |
|
|
|
|
import apiMetrics from '../../helpers/apiMetrics'; |
|
|
|
|
import getAst from '../../../db/sql-data-mapper/lib/sql/helpers/getAst'; |
|
|
|
|
import { parseHrtimeToSeconds } from '../helpers'; |
|
|
|
|
|
|
|
|
|
// todo: Handle the error case where view doesnt belong to model
|
|
|
|
|
async function dataList(req: Request, res: Response) { |
|
|
|
|
const startTime = process.hrtime(); |
|
|
|
|
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); |
|
|
|
|
res.json(await getDataList(model, view, req)); |
|
|
|
|
const responseData = await getDataList(model, view, req); |
|
|
|
|
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime)); |
|
|
|
|
res.setHeader('xc-db-response', elapsedSeconds); |
|
|
|
|
res.json(responseData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function dataFindOne(req: Request, res: Response) { |
|
|
|
@ -226,8 +231,12 @@ async function dataExist(req: Request, res: Response) {
|
|
|
|
|
|
|
|
|
|
// todo: Handle the error case where view doesnt belong to model
|
|
|
|
|
async function groupedDataList(req: Request, res: Response) { |
|
|
|
|
const startTime = process.hrtime(); |
|
|
|
|
const { model, view } = await getViewAndModelFromRequestByAliasOrId(req); |
|
|
|
|
res.json(await getGroupedDataList(model, view, req)); |
|
|
|
|
const groupedData = await getGroupedDataList(model, view, req); |
|
|
|
|
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(startTime)); |
|
|
|
|
res.setHeader('xc-db-response', elapsedSeconds); |
|
|
|
|
res.json(groupedData); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function getGroupedDataList(model, view: View, req) { |
|
|
|
|