Browse Source

fix(api): improve kanban api

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3818/head
Pranav C 2 years ago
parent
commit
98a03008ea
  1. 11
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts
  2. 11
      packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

11
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2334,8 +2334,7 @@ class BaseModelSqlv2 {
args: { args: {
groupColumnId: string; groupColumnId: string;
ignoreFilterSort?: boolean; ignoreFilterSort?: boolean;
sortArr?: any; options?: (string | number | null | boolean)[];
filterArr?: any;
} & Partial<XcFilter> } & Partial<XcFilter>
): Promise< ): Promise<
{ {
@ -2355,7 +2354,9 @@ class BaseModelSqlv2 {
// extract distinct group column values // extract distinct group column values
let groupingValues; let groupingValues;
if (column.uidt === UITypes.SingleSelect) { if (args.options?.length) {
groupingValues = args.options;
} else if (column.uidt === UITypes.SingleSelect) {
const colOptions = await column.getColOptions< const colOptions = await column.getColOptions<
SelectOption[] & { options } SelectOption[] & { options }
>(); >();
@ -2474,9 +2475,9 @@ class BaseModelSqlv2 {
const groupedResult: Record<string, Record<string, unknown>[]> = const groupedResult: Record<string, Record<string, unknown>[]> =
_.groupBy(result, column.title); _.groupBy(result, column.title);
const r = Object.entries(groupedResult).map(([key, value]) => ({ const r = groupingValues.map((key) => ({
key, key,
value, value: groupedResult[key] ?? [],
})); }));
return r; return r;

11
packages/nocodb/src/lib/meta/api/dataApis/dataAliasApis.ts

@ -246,6 +246,9 @@ async function getGroupedDataList(model, view: View, req) {
try { try {
listArgs.sortArr = JSON.parse(listArgs.sortArrJson); listArgs.sortArr = JSON.parse(listArgs.sortArrJson);
} catch (e) {} } catch (e) {}
try {
listArgs.options = JSON.parse(listArgs.optionsArrJson);
} catch (e) {}
let data = []; let data = [];
// let count = 0 // let count = 0
@ -266,13 +269,13 @@ async function getGroupedDataList(model, view: View, req) {
}); });
data = data.map((item) => { data = data.map((item) => {
// todo: use map to avoid loop // todo: use map to avoid loop
const count = countArr.find( const count =
(countItem) => countItem.key || 'null' === item.key countArr.find((countItem) => countItem.key || 'null' === item.key)
)?.count; ?.count ?? 0;
item.value = new PagedResponseImpl(item.value, { item.value = new PagedResponseImpl(item.value, {
...req.query, ...req.query,
count, count: count,
}); });
return item; return item;
}); });

Loading…
Cancel
Save