Исправлена функция обновления дерева
This commit is contained in:
parent
e9d808a19d
commit
9568b12280
3 changed files with 42 additions and 10 deletions
|
|
@ -9,6 +9,7 @@ import { MemoryCache } from '../utils/memory-cache';
|
|||
import nano from 'nano';
|
||||
import { UNLIMITED } from '../consts/consts';
|
||||
import { GetParentsHint } from '../utils/get-parents-hint';
|
||||
import { TreeIssuesStore } from '../utils/tree-issues-store';
|
||||
|
||||
export const ISSUE_MEMORY_CACHE_LIFETIME = 30 * 1000;
|
||||
const ISSUE_MEMORY_CACHE_AUTOCLEAN_INTERVAL = 1000 * 60 * 5;
|
||||
|
|
@ -165,4 +166,14 @@ export class IssuesService {
|
|||
};
|
||||
return fn;
|
||||
}
|
||||
|
||||
async getIssuesWithChildren(
|
||||
rootIssue: RedmineTypes.Issue,
|
||||
): Promise<RedmineTypes.Issue[]> {
|
||||
const treeIssuesStore = new TreeIssuesStore();
|
||||
treeIssuesStore.setRootIssue(rootIssue);
|
||||
const loader = this.createDynamicIssuesLoader();
|
||||
await treeIssuesStore.fillData(loader);
|
||||
return treeIssuesStore.getIssuesWithChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,4 +189,25 @@ export class TreeIssuesStore {
|
|||
}
|
||||
return stories;
|
||||
}
|
||||
|
||||
getIssuesWithChildren(): RedmineTypes.Issue[] {
|
||||
return this.fillIssuesWithChildren(this.rootIssue, []);
|
||||
}
|
||||
|
||||
private fillIssuesWithChildren(
|
||||
issue: RedmineTypes.Issue,
|
||||
data: RedmineTypes.Issue[],
|
||||
): RedmineTypes.Issue[] {
|
||||
if (!issue || !issue.children || issue.children.length <= 0) return;
|
||||
for (let i = 0; i < issue.children.length; i++) {
|
||||
const childIssueResult = this.getFlatStore().getIssue(
|
||||
issue.children[i].id,
|
||||
);
|
||||
if (!childIssueResult || !childIssueResult.data) continue;
|
||||
const childIssue = childIssueResult.data;
|
||||
data.push(childIssue);
|
||||
this.fillIssuesWithChildren(childIssue, data);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { DynamicLoader } from '@app/event-emitter/configs/dynamic-loader';
|
||||
import { RedmineEventsGateway } from '@app/event-emitter/events/redmine-events.gateway';
|
||||
import { IssuesService } from '@app/event-emitter/issues/issues.service';
|
||||
import { ListIssuesByFieldsWidgetService } from '@app/event-emitter/project-dashboard/widgets/list-issues-by-fields.widget.service';
|
||||
import { ListIssuesByUsersLikeJiraWidgetService } from '@app/event-emitter/project-dashboard/widgets/list-issues-by-users-like-jira.widget.service';
|
||||
import { ListIssuesByUsersWidgetService } from '@app/event-emitter/project-dashboard/widgets/list-issues-by-users.widget.service';
|
||||
|
|
@ -7,13 +8,15 @@ import {
|
|||
RootIssueSubTreesWidgetNs,
|
||||
RootIssueSubTreesWidgetService,
|
||||
} from '@app/event-emitter/project-dashboard/widgets/root-issue-subtrees.widget.service';
|
||||
import { Controller, Get, Param, Render } from '@nestjs/common';
|
||||
import { TreeIssuesStore } from '@app/event-emitter/utils/tree-issues-store';
|
||||
import { Controller, Get, Logger, Param, Render } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { parse } from 'jsonc-parser';
|
||||
import { IssuesByTagsWidgetService } from './widgets/issues-by-tags.widget.service';
|
||||
|
||||
@Controller('simple-kanban-board')
|
||||
export class SimpleKanbanBoardController {
|
||||
private logger = new Logger(SimpleKanbanBoardController.name);
|
||||
private path: string;
|
||||
|
||||
constructor(
|
||||
|
|
@ -25,6 +28,7 @@ export class SimpleKanbanBoardController {
|
|||
private issuesByTagsWidgetService: IssuesByTagsWidgetService,
|
||||
private redmineEventsGateway: RedmineEventsGateway,
|
||||
private listIssuesByFieldsWidgetService: ListIssuesByFieldsWidgetService,
|
||||
private issuesService: IssuesService,
|
||||
) {
|
||||
this.path = this.configService.get<string>('simpleKanbanBoard.path');
|
||||
}
|
||||
|
|
@ -52,15 +56,11 @@ export class SimpleKanbanBoardController {
|
|||
ext: 'jsonc',
|
||||
parser: parse,
|
||||
});
|
||||
const issues = [] as number[];
|
||||
issues.push(cfg.rootIssueId);
|
||||
if (cfg.groups) {
|
||||
const groups = cfg.groups as RootIssueSubTreesWidgetNs.Models.GroupCfg;
|
||||
groups.fromIssues.forEach((group) => {
|
||||
issues.push(group.issueId);
|
||||
});
|
||||
}
|
||||
this.redmineEventsGateway.addIssues(issues);
|
||||
const rootIssue = await this.issuesService.getIssueFromCache(
|
||||
cfg.rootIssueId,
|
||||
);
|
||||
const issues = await this.issuesService.getIssuesWithChildren(rootIssue);
|
||||
this.logger.debug(`Issues for tree refresh - ${issues}`); // DEBUG
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue