-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
12 changed files
with
141 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
npm --prefix teammapper-backend run typeorm:prod:migrate | ||
npm --prefix teammapper-backend run prod:typeorm:migrate | ||
npm run start:prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { MapsService } from '../map/services/maps.service'; | ||
import AppModule from '../app.module'; | ||
import { Logger } from '@nestjs/common'; | ||
import configService from '../config.service'; | ||
import { DeleteResult } from 'typeorm'; | ||
|
||
async function bootstrap() { | ||
const application = await NestFactory.createApplicationContext( | ||
AppModule, | ||
); | ||
|
||
const logger = new Logger('TaskRunner'); | ||
const mapsService = application.get(MapsService); | ||
|
||
logger.log('--- Deleting old maps ... ---'); | ||
const result: DeleteResult = await mapsService.deleteOutdatedMaps(configService.deleteAfterDays()); | ||
logger.log('Deleted rows: ' + result.affected); | ||
logger.log('--- Finished deleting maps ---'); | ||
|
||
await application.close(); | ||
process.exit(0); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { MapsService } from '../map/services/maps.service'; | ||
import AppModule from '../app.module'; | ||
import { Logger } from '@nestjs/common'; | ||
import { IMmpClientMap, IMmpClientNode } from 'src/map/types'; | ||
import * as crypto from 'crypto'; | ||
|
||
const createNode: any = (isRoot: boolean, parentId: string, x: number, y: number) => { | ||
return { | ||
colors: { | ||
name: '#000000', | ||
background: '#FF0000', | ||
branch: '#000000', | ||
}, | ||
coordinates: { x: x, y: y }, | ||
font: { | ||
style: '', | ||
size: 10, | ||
weight: 'bold', | ||
}, | ||
id: crypto.randomUUID(), | ||
image: { | ||
src: '', | ||
size: 0, | ||
}, | ||
k: 0, | ||
locked: false, | ||
name: 'Seed Data', | ||
parent: parentId, | ||
isRoot: isRoot, | ||
}; | ||
}; | ||
|
||
const createMap: any = (nodes: IMmpClientNode[]) => { | ||
return { | ||
uuid: crypto.randomUUID(), | ||
lastModified: new Date(), | ||
deleteAfterDays: 30, | ||
data: nodes, | ||
deletedAt: undefined, | ||
}; | ||
}; | ||
|
||
async function bootstrap() { | ||
const application = await NestFactory.createApplicationContext( | ||
AppModule, | ||
); | ||
|
||
const logger = new Logger('TaskRunner'); | ||
const mapsService = application.get(MapsService); | ||
|
||
logger.log('--- Creating maps ... ---'); | ||
|
||
for (let i = 0; i < 5000; i++) { | ||
const rootNode: IMmpClientNode = createNode(true, '', 0, 0); | ||
const childNode: IMmpClientNode = createNode(false, rootNode.id, 150, 150); | ||
const secondChildNode: IMmpClientNode = createNode(false, childNode.id, 250, 250); | ||
const mapData: IMmpClientMap = createMap([rootNode, childNode, secondChildNode]); | ||
await mapsService.createMap(mapData); | ||
logger.log(`--- Map created with id ${mapData.uuid} ---`); | ||
} | ||
|
||
logger.log('--- Finished creating maps ---'); | ||
|
||
await application.close(); | ||
process.exit(0); | ||
} | ||
|
||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
teammapper-backend/src/migrations/1663839669273-AddIndexToForeignKeysOnMmpNode.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddIndexToForeignKeysOnMmpNode1663839669273 implements MigrationInterface { | ||
name = 'AddIndexToForeignKeysOnMmpNode1663839669273' | ||
name = 'AddIndexToForeignKeysOnMmpNode1663839669273'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE INDEX "IDX_19c5208da416d32ea491315716" ON "mmp_node" ("nodeMapId") `); | ||
} | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('CREATE INDEX "IDX_19c5208da416d32ea491315716" ON "mmp_node" ("nodeMapId") '); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "public"."IDX_19c5208da416d32ea491315716"`); | ||
} | ||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('DROP INDEX "public"."IDX_19c5208da416d32ea491315716"'); | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
teammapper-backend/src/migrations/1663927754319-AddIndexForNodesParents.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
|
||
export class AddIndexForNodesParents1663927754319 implements MigrationInterface { | ||
name = 'AddIndexForNodesParents1663927754319' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE INDEX "IDX_336300b82c56a05f0317f22942" ON "mmp_node" ("nodeMapId", "nodeParentId") `); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "public"."IDX_336300b82c56a05f0317f22942"`); | ||
} | ||
} |