|
|
|
@ -1,11 +1,14 @@
@@ -1,11 +1,14 @@
|
|
|
|
|
import { Inject, Injectable } from '@nestjs/common' |
|
|
|
|
import { InjectConnection } from '@nestjs/typeorm' |
|
|
|
|
import { Tasks, Taxonomies, Users } from 'src/core' |
|
|
|
|
import { TASKS_EVENTS_SERVICE, TASKS_SERVICE, TAXONOMIES_SERVICE } from 'src/core/consts' |
|
|
|
|
import { TASKS_EVENTS_SERVICE, TAXONOMIES_SERVICE } from 'src/core/consts' |
|
|
|
|
import { TASKS_REPOSITORY } from 'src/domain/tasks/consts' |
|
|
|
|
import { ITasksRepository } from 'src/domain/tasks/interfaces' |
|
|
|
|
import { TAXONOMIES_REPOSITORY } from 'src/domain/taxonomies/consts' |
|
|
|
|
import { ITaxonomiesRepository } from 'src/domain/taxonomies/interfaces' |
|
|
|
|
import { USERS_REPOSITORY } from 'src/domain/users/consts' |
|
|
|
|
import { IUsersRepository } from 'src/domain/users/interfaces' |
|
|
|
|
import { dateToSqlFormat } from 'src/shared' |
|
|
|
|
import { Connection, Repository } from 'typeorm' |
|
|
|
|
import { OldDbRelation } from '../entities' |
|
|
|
|
import { OLD_DB_RELATIONS_REPOSITORY } from '../typing/consts' |
|
|
|
@ -14,7 +17,6 @@ import { IOldTask } from '../typing/interfaces'
@@ -14,7 +17,6 @@ import { IOldTask } from '../typing/interfaces'
|
|
|
|
|
|
|
|
|
|
@Injectable() |
|
|
|
|
export class OldDBTasksService { |
|
|
|
|
@Inject(TASKS_SERVICE) private readonly tasksService: Tasks.ITasksService |
|
|
|
|
@Inject(OLD_DB_RELATIONS_REPOSITORY) |
|
|
|
|
private readonly oldDbRelationsRepository: Repository<OldDbRelation> |
|
|
|
|
@Inject(TAXONOMIES_REPOSITORY) |
|
|
|
@ -25,12 +27,12 @@ export class OldDBTasksService {
@@ -25,12 +27,12 @@ export class OldDBTasksService {
|
|
|
|
|
private readonly usersRepository: IUsersRepository |
|
|
|
|
@Inject(TASKS_EVENTS_SERVICE) |
|
|
|
|
private readonly tasksEventsService: Tasks.ITasksEventsService |
|
|
|
|
@Inject(TASKS_REPOSITORY) private readonly tasksRepository: ITasksRepository |
|
|
|
|
|
|
|
|
|
constructor(@InjectConnection('old') private readonly connection: Connection) {} |
|
|
|
|
|
|
|
|
|
public async run() { |
|
|
|
|
const oldTasks = await this.getOldTasks() |
|
|
|
|
|
|
|
|
|
for await (const oldTask of oldTasks) { |
|
|
|
|
try { |
|
|
|
|
await this.saveTask(oldTask) |
|
|
|
@ -66,11 +68,12 @@ export class OldDBTasksService {
@@ -66,11 +68,12 @@ export class OldDBTasksService {
|
|
|
|
|
: new Date(Number(oldTask.created_at)).toDateString() |
|
|
|
|
const status = this.getStatus(oldTask) |
|
|
|
|
|
|
|
|
|
const task = await this.tasksService.saveTask({ |
|
|
|
|
const task = await this.tasksRepository.save({ |
|
|
|
|
id: oldTask.id, |
|
|
|
|
name: oldTask.name, |
|
|
|
|
description: oldTask.description, |
|
|
|
|
startDate: oldTask.start_date, |
|
|
|
|
endDate: oldTask.end_date, |
|
|
|
|
startDate: dateToSqlFormat(new Date(oldTask.start_date)), |
|
|
|
|
endDate: dateToSqlFormat(new Date(oldTask.end_date)), |
|
|
|
|
groupId: newGroupId, |
|
|
|
|
reasonId: newReasonId, |
|
|
|
|
authorId: newAuthorId, |
|
|
|
@ -79,11 +82,14 @@ export class OldDBTasksService {
@@ -79,11 +82,14 @@ export class OldDBTasksService {
|
|
|
|
|
createdAt, |
|
|
|
|
doneDate: oldTask.done_date, |
|
|
|
|
status, |
|
|
|
|
isReadByAll: true, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
await this.tasksRepository.update(task.id, { id: oldTask.id }) |
|
|
|
|
|
|
|
|
|
await this.oldDbRelationsRepository.insert({ |
|
|
|
|
oldId: oldTask.id, |
|
|
|
|
newId: task.id, |
|
|
|
|
newId: oldTask.id, |
|
|
|
|
type: OldDbRelationType.Tasks, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|