chore(*): remove unused code (#6781)
The code removed in the PR was flagged as unused by the JetBrains inspector. I did a QA on the dev environment but other checks are highly recommended. There is one commit by scope to make the review easier. --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -20,7 +20,7 @@ export abstract class AbstractWorkspaceFixer<
|
||||
> {
|
||||
private issueTypes: IssueTypes[];
|
||||
|
||||
constructor(...issueTypes: IssueTypes[]) {
|
||||
protected constructor(...issueTypes: IssueTypes[]) {
|
||||
this.issueTypes = issueTypes;
|
||||
}
|
||||
|
||||
|
||||
@ -112,13 +112,12 @@ export class WorkspaceDefaultValueFixer extends AbstractWorkspaceFixer<Workspace
|
||||
|
||||
for (const issue of issues) {
|
||||
const currentDefaultValue:
|
||||
| FieldMetadataDefaultValue<'default'>
|
||||
| FieldMetadataDefaultValue
|
||||
// Old format for default values
|
||||
// TODO: Remove this after all workspaces are migrated
|
||||
| { type: FieldMetadataDefaultValueFunctionNames }
|
||||
| null = issue.fieldMetadata.defaultValue;
|
||||
let alteredDefaultValue: FieldMetadataDefaultValue<'default'> | null =
|
||||
null;
|
||||
let alteredDefaultValue: FieldMetadataDefaultValue | null = null;
|
||||
|
||||
// Check if it's an old function default value
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
@ -189,7 +188,7 @@ export class WorkspaceDefaultValueFixer extends AbstractWorkspaceFixer<Workspace
|
||||
|
||||
private computeFieldMetadataDefaultValueFromColumnDefault(
|
||||
columnDefault: string | undefined,
|
||||
): FieldMetadataDefaultValue<'default'> {
|
||||
): FieldMetadataDefaultValue {
|
||||
if (
|
||||
columnDefault === undefined ||
|
||||
columnDefault === null ||
|
||||
|
||||
@ -151,24 +151,6 @@ export class DatabaseStructureService {
|
||||
}));
|
||||
}
|
||||
|
||||
async workspaceColumnExist(
|
||||
schemaName: string,
|
||||
tableName: string,
|
||||
columnName: string,
|
||||
): Promise<boolean> {
|
||||
const mainDataSource = this.typeORMService.getMainDataSource();
|
||||
const results = await mainDataSource.query(
|
||||
`SELECT column_name
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = $1
|
||||
AND table_name = $2
|
||||
AND column_name = $3`,
|
||||
[schemaName, tableName, columnName],
|
||||
);
|
||||
|
||||
return results.length >= 1;
|
||||
}
|
||||
|
||||
getPostgresDataTypes(fieldMetadata: FieldMetadataEntity): string[] {
|
||||
const mainDataSource = this.typeORMService.getMainDataSource();
|
||||
|
||||
|
||||
@ -76,22 +76,6 @@ export class WorkspaceManagerService {
|
||||
await this.prefillWorkspaceWithDemoObjects(dataSourceMetadata, workspaceId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Check if the workspace schema has already been created or not
|
||||
*
|
||||
* @param workspaceId
|
||||
* @Returns Promise<boolean>
|
||||
*/
|
||||
public async doesDataSourceExist(workspaceId: string): Promise<boolean> {
|
||||
const dataSource =
|
||||
await this.dataSourceService.getDataSourcesMetadataFromWorkspaceId(
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
return dataSource.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* We are updating the pg_graphql max_rows from 30 (default value) to 60
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import {
|
||||
QueryRunner,
|
||||
@ -32,8 +32,6 @@ import { customTableDefaultColumns } from './utils/custom-table-default-column.u
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceMigrationRunnerService {
|
||||
private readonly logger = new Logger(WorkspaceMigrationRunnerService.name);
|
||||
|
||||
constructor(
|
||||
private readonly workspaceDataSourceService: WorkspaceDataSourceService,
|
||||
private readonly workspaceMigrationService: WorkspaceMigrationService,
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
import { PartialFieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/partial-field-metadata.interface';
|
||||
import { PartialWorkspaceEntity } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/partial-object-metadata.interface';
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
|
||||
export type MappedFieldMetadata = Record<string, PartialFieldMetadata>;
|
||||
|
||||
export interface MappedWorkspaceEntity
|
||||
extends Omit<PartialWorkspaceEntity, 'fields'> {
|
||||
fields: MappedFieldMetadata;
|
||||
}
|
||||
|
||||
export type MappedFieldMetadataEntity = Record<string, FieldMetadataEntity>;
|
||||
|
||||
export interface MappedObjectMetadataEntity
|
||||
extends Omit<ObjectMetadataEntity, 'fields'> {
|
||||
fields: MappedFieldMetadataEntity;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import {
|
||||
EntityManager,
|
||||
@ -27,8 +27,6 @@ import { WorkspaceSyncStorage } from 'src/engine/workspace-manager/workspace-syn
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceMetadataUpdaterService {
|
||||
private readonly logger = new Logger(WorkspaceMetadataUpdaterService.name);
|
||||
|
||||
async updateObjectMetadata(
|
||||
manager: EntityManager,
|
||||
storage: WorkspaceSyncStorage,
|
||||
@ -127,12 +125,13 @@ export class WorkspaceMetadataUpdaterService {
|
||||
/**
|
||||
* Update field metadata
|
||||
*/
|
||||
const updatedFieldMetadataCollection = await this.updateEntities<
|
||||
FieldMetadataEntity<'default'>
|
||||
>(manager, FieldMetadataEntity, storage.fieldMetadataUpdateCollection, [
|
||||
'objectMetadataId',
|
||||
'workspaceId',
|
||||
]);
|
||||
const updatedFieldMetadataCollection =
|
||||
await this.updateEntities<FieldMetadataEntity>(
|
||||
manager,
|
||||
FieldMetadataEntity,
|
||||
storage.fieldMetadataUpdateCollection,
|
||||
['objectMetadataId', 'workspaceId'],
|
||||
);
|
||||
|
||||
/**
|
||||
* Create field metadata
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { EntityManager, Repository } from 'typeorm';
|
||||
|
||||
@ -17,10 +17,6 @@ import { mapObjectMetadataByUniqueIdentifier } from 'src/engine/workspace-manage
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceSyncObjectMetadataIdentifiersService {
|
||||
private readonly logger = new Logger(
|
||||
WorkspaceSyncObjectMetadataIdentifiersService.name,
|
||||
);
|
||||
|
||||
constructor(private readonly standardObjectFactory: StandardObjectFactory) {}
|
||||
|
||||
async synchronize(
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { EntityManager } from 'typeorm';
|
||||
|
||||
@ -21,10 +21,6 @@ import { CustomWorkspaceEntity } from 'src/engine/twenty-orm/custom.workspace-en
|
||||
|
||||
@Injectable()
|
||||
export class WorkspaceSyncRelationMetadataService {
|
||||
private readonly logger = new Logger(
|
||||
WorkspaceSyncRelationMetadataService.name,
|
||||
);
|
||||
|
||||
constructor(
|
||||
private readonly standardRelationFactory: StandardRelationFactory,
|
||||
private readonly workspaceRelationComparator: WorkspaceRelationComparator,
|
||||
|
||||
@ -84,10 +84,6 @@ export class WorkspaceSyncStorage {
|
||||
return this._indexMetadataCreateCollection;
|
||||
}
|
||||
|
||||
get indexMetadataUpdateCollection() {
|
||||
return this._indexMetadataUpdateCollection;
|
||||
}
|
||||
|
||||
get indexMetadataDeleteCollection() {
|
||||
return this._indexMetadataDeleteCollection;
|
||||
}
|
||||
@ -138,10 +134,6 @@ export class WorkspaceSyncStorage {
|
||||
this._indexMetadataCreateCollection.push(index);
|
||||
}
|
||||
|
||||
addUpdateIndexMetadata(index: Partial<IndexMetadataEntity>) {
|
||||
this._indexMetadataUpdateCollection.push(index);
|
||||
}
|
||||
|
||||
addDeleteIndexMetadata(index: IndexMetadataEntity) {
|
||||
this._indexMetadataDeleteCollection.push(index);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* Each object in the map contains the original object metadata and its fields as a nested map.
|
||||
*
|
||||
* @param arr - The array of ObjectMetadataEntity objects to convert.
|
||||
* @param keyFactory
|
||||
* @returns A map of object metadata, with nameSingular as the key and the object as the value.
|
||||
*/
|
||||
export const mapObjectMetadataByUniqueIdentifier = <
|
||||
|
||||
@ -42,8 +42,8 @@ export class WorkspaceSyncMetadataService {
|
||||
* Sync all standard objects and fields metadata for a given workspace and data source
|
||||
* This will update the metadata if it has changed and generate migrations based on the diff.
|
||||
*
|
||||
* @param dataSourceId
|
||||
* @param workspaceId
|
||||
* @param context
|
||||
* @param options
|
||||
*/
|
||||
public async synchronize(
|
||||
context: WorkspaceSyncContext,
|
||||
|
||||
Reference in New Issue
Block a user