Browse Source

chore: lint

pull/7777/head
Pranav C 9 months ago
parent
commit
abd2adb2f9
  1. 9
      packages/nocodb/src/helpers/formulaHelpers.ts
  2. 16
      packages/nocodb/src/models/Filter.ts
  3. 6
      packages/nocodb/src/models/Model.ts
  4. 36
      packages/nocodb/src/models/View.ts

9
packages/nocodb/src/helpers/formulaHelpers.ts

@ -2,15 +2,18 @@ import jsep from 'jsep';
import { UITypes } from 'nocodb-sdk'; import { UITypes } from 'nocodb-sdk';
import type FormulaColumn from '../models/FormulaColumn'; import type FormulaColumn from '../models/FormulaColumn';
import type { Column } from '~/models'; import type { Column } from '~/models';
import Noco from "~/Noco"; import Noco from '~/Noco';
export async function getFormulasReferredTheColumn({ export async function getFormulasReferredTheColumn(
{
column, column,
columns, columns,
}: { }: {
column: Column; column: Column;
columns: Column[]; columns: Column[];
}, ncMeta = Noco.ncMeta): Promise<Column[]> { },
ncMeta = Noco.ncMeta,
): Promise<Column[]> {
const fn = (pt) => { const fn = (pt) => {
if (pt.type === 'CallExpression') { if (pt.type === 'CallExpression') {
return pt.arguments.some((arg) => fn(arg)); return pt.arguments.some((arg) => fn(arg));

16
packages/nocodb/src/models/Filter.ts

@ -251,9 +251,11 @@ export default class Filter implements FilterType {
// if not a view filter then no need to delete // if not a view filter then no need to delete
if (filter.fk_view_id) { if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta); const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [ await View.clearSingleQueryCache(
{ id: filter.fk_view_id }, view.fk_model_id,
], ncMeta); [{ id: filter.fk_view_id }],
ncMeta,
);
} }
} }
@ -281,9 +283,11 @@ export default class Filter implements FilterType {
if (filter.fk_view_id) { if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta); const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [ await View.clearSingleQueryCache(
{ id: filter.fk_view_id }, view.fk_model_id,
], ncMeta); [{ id: filter.fk_view_id }],
ncMeta,
);
} }
} }
} }

6
packages/nocodb/src/models/Model.ts

@ -687,7 +687,11 @@ export default class Model implements TableType {
if (colOptions.fk_related_model_id === tableId) continue; if (colOptions.fk_related_model_id === tableId) continue;
await View.clearSingleQueryCache(colOptions.fk_related_model_id, null, ncMeta); await View.clearSingleQueryCache(
colOptions.fk_related_model_id,
null,
ncMeta,
);
} }
return res; return res;

36
packages/nocodb/src/models/View.ts

@ -1472,11 +1472,39 @@ export default class View implements ViewType {
} }
public static async clearSingleQueryCache( public static async clearSingleQueryCache(
_modelId: string, modelId: string,
_views?: { id?: string }[], views?: { id?: string }[],
_ncMeta = Noco.ncMeta, ncMeta = Noco.ncMeta,
) { ) {
// do nothing if (!Noco.isEE()) return;
// get all views of the model
let viewsList =
views || (await NocoCache.getList(CacheScope.VIEW, [modelId])).list;
if (!views && !viewsList?.length) {
viewsList = await ncMeta.metaList2(null, null, MetaTable.VIEWS, {
condition: {
fk_model_id: modelId,
},
});
}
const deleteKeys = [];
for (const view of viewsList) {
deleteKeys.push(
`${CacheScope.SINGLE_QUERY}:${modelId}:${view.id}:queries`,
`${CacheScope.SINGLE_QUERY}:${modelId}:${view.id}:read`,
);
}
deleteKeys.push(
`${CacheScope.SINGLE_QUERY}:${modelId}:default:queries`,
`${CacheScope.SINGLE_QUERY}:${modelId}:default:read`,
);
await NocoCache.del(deleteKeys);
} }
static async bulkColumnInsertToViews( static async bulkColumnInsertToViews(

Loading…
Cancel
Save