Browse Source

chore: lint

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

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

@ -2,15 +2,18 @@ import jsep from 'jsep';
import { UITypes } from 'nocodb-sdk';
import type FormulaColumn from '../models/FormulaColumn';
import type { Column } from '~/models';
import Noco from "~/Noco";
import Noco from '~/Noco';
export async function getFormulasReferredTheColumn({
column,
columns,
}: {
column: Column;
columns: Column[];
}, ncMeta = Noco.ncMeta): Promise<Column[]> {
export async function getFormulasReferredTheColumn(
{
column,
columns,
}: {
column: Column;
columns: Column[];
},
ncMeta = Noco.ncMeta,
): Promise<Column[]> {
const fn = (pt) => {
if (pt.type === 'CallExpression') {
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 (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [
{ id: filter.fk_view_id },
], ncMeta);
await View.clearSingleQueryCache(
view.fk_model_id,
[{ id: filter.fk_view_id }],
ncMeta,
);
}
}
@ -281,9 +283,11 @@ export default class Filter implements FilterType {
if (filter.fk_view_id) {
const view = await View.get(filter.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [
{ id: filter.fk_view_id },
], ncMeta);
await View.clearSingleQueryCache(
view.fk_model_id,
[{ 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;
await View.clearSingleQueryCache(colOptions.fk_related_model_id, null, ncMeta);
await View.clearSingleQueryCache(
colOptions.fk_related_model_id,
null,
ncMeta,
);
}
return res;

2
packages/nocodb/src/models/Sort.ts

@ -95,7 +95,7 @@ export default class Sort {
// on insert, delete any optimised single query cache
{
const view = await View.get(row.fk_view_id, ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view],ncMeta);
await View.clearSingleQueryCache(view.fk_model_id, [view], ncMeta);
}
return this.get(row.id, ncMeta).then(async (sort) => {

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

@ -1472,11 +1472,39 @@ export default class View implements ViewType {
}
public static async clearSingleQueryCache(
_modelId: string,
_views?: { id?: string }[],
_ncMeta = Noco.ncMeta,
modelId: string,
views?: { id?: string }[],
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(

Loading…
Cancel
Save