Browse Source

feat: all project meta api

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5444/head
Pranav C 2 years ago
parent
commit
738ff25990
  1. 27
      packages/nocodb-nest/src/modules/utils/utils.service.ts

27
packages/nocodb-nest/src/modules/utils/utils.service.ts

@ -1,14 +1,16 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import axios from 'axios'; import axios from 'axios';
import { compareVersions, validate } from 'compare-versions'; import { compareVersions, validate } from 'compare-versions';
import { ViewTypes } from 'nocodb-sdk';
import { NC_ATTACHMENT_FIELD_SIZE } from '../../constants'; import { NC_ATTACHMENT_FIELD_SIZE } from '../../constants';
import SqlMgrv2 from '../../db/sql-mgr/v2/SqlMgrv2' import SqlMgrv2 from '../../db/sql-mgr/v2/SqlMgrv2';
import { NcError } from '../../helpers/catchError'; import { NcError } from '../../helpers/catchError';
import { User } from '../../models'; import { Project, User } from '../../models';
import Noco from '../../Noco' import Noco from '../../Noco';
import NcConnectionMgrv2 from '../../utils/common/NcConnectionMgrv2';
import { MetaTable } from '../../utils/globals';
import NcConfigFactory from '../../utils/NcConfigFactory'; import NcConfigFactory from '../../utils/NcConfigFactory';
import { packageVersion } from '../../utils/packageVersion'; import { packageVersion } from '../../utils/packageVersion';
// import { packageVersion } from '../packageVersion';
const versionCache = { const versionCache = {
releaseVersion: null, releaseVersion: null,
@ -233,12 +235,10 @@ export class UtilsService {
} }
async aggregatedMetaInfo() { async aggregatedMetaInfo() {
const projects = []; const [projects, userCount] = await Promise.all([
const userCount = 0; Project.list({}),
// const [projects, userCount] = await Promise.all([ Noco.ncMeta.metaCount(null, null, MetaTable.USERS),
// Project.list({}), ]);
// Noco.ncMeta.metaCount(null, null, MetaTable.USERS),
// ]);
const result: AllMeta = { const result: AllMeta = {
projectCount: projects.length, projectCount: projects.length,
@ -247,8 +247,7 @@ export class UtilsService {
sharedBaseCount: 0, sharedBaseCount: 0,
}; };
// todo: tobe done result.projects.push(
/* result.projects.push(
...this.extractResultOrNull( ...this.extractResultOrNull(
await Promise.allSettled( await Promise.allSettled(
projects.map(async (project) => { projects.map(async (project) => {
@ -284,7 +283,7 @@ export class UtilsService {
MetaTable.VIEWS, MetaTable.VIEWS,
); );
// grid, form, gallery, kanban and shared count // grid, form, gallery, kanban and shared count
return views.reduce<ViewCount>( return (views as any[]).reduce<ViewCount>(
(out, view) => { (out, view) => {
out.total++; out.total++;
@ -369,7 +368,7 @@ export class UtilsService {
}), }),
), ),
), ),
);*/ );
return result; return result;
} }

Loading…
Cancel
Save