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: {
groupColumnId: string;
ignoreFilterSort?: boolean;
sortArr?: any;
filterArr?: any;
options?: (string | number | null | boolean)[];
} & Partial<XcFilter>
): Promise<
{
@ -2355,7 +2354,9 @@ class BaseModelSqlv2 {
// extract distinct group column values
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<
SelectOption[] & { options }
>();
@ -2474,9 +2475,9 @@ class BaseModelSqlv2 {
const groupedResult: Record<string, Record<string, unknown>[]> =
_.groupBy(result, column.title);
const r = Object.entries(groupedResult).map(([key, value]) => ({
const r = groupingValues.map((key) => ({
key,
value,
value: groupedResult[key] ?? [],
}));
return r;

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

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

Loading…
Cancel
Save