Исправлена функция обновления дерева
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 nano from 'nano';
|
||||||
import { UNLIMITED } from '../consts/consts';
|
import { UNLIMITED } from '../consts/consts';
|
||||||
import { GetParentsHint } from '../utils/get-parents-hint';
|
import { GetParentsHint } from '../utils/get-parents-hint';
|
||||||
|
import { TreeIssuesStore } from '../utils/tree-issues-store';
|
||||||
|
|
||||||
export const ISSUE_MEMORY_CACHE_LIFETIME = 30 * 1000;
|
export const ISSUE_MEMORY_CACHE_LIFETIME = 30 * 1000;
|
||||||
const ISSUE_MEMORY_CACHE_AUTOCLEAN_INTERVAL = 1000 * 60 * 5;
|
const ISSUE_MEMORY_CACHE_AUTOCLEAN_INTERVAL = 1000 * 60 * 5;
|
||||||
|
|
@ -165,4 +166,14 @@ export class IssuesService {
|
||||||
};
|
};
|
||||||
return fn;
|
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;
|
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 { DynamicLoader } from '@app/event-emitter/configs/dynamic-loader';
|
||||||
import { RedmineEventsGateway } from '@app/event-emitter/events/redmine-events.gateway';
|
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 { 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 { 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';
|
import { ListIssuesByUsersWidgetService } from '@app/event-emitter/project-dashboard/widgets/list-issues-by-users.widget.service';
|
||||||
|
|
@ -7,13 +8,15 @@ import {
|
||||||
RootIssueSubTreesWidgetNs,
|
RootIssueSubTreesWidgetNs,
|
||||||
RootIssueSubTreesWidgetService,
|
RootIssueSubTreesWidgetService,
|
||||||
} from '@app/event-emitter/project-dashboard/widgets/root-issue-subtrees.widget.service';
|
} 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 { ConfigService } from '@nestjs/config';
|
||||||
import { parse } from 'jsonc-parser';
|
import { parse } from 'jsonc-parser';
|
||||||
import { IssuesByTagsWidgetService } from './widgets/issues-by-tags.widget.service';
|
import { IssuesByTagsWidgetService } from './widgets/issues-by-tags.widget.service';
|
||||||
|
|
||||||
@Controller('simple-kanban-board')
|
@Controller('simple-kanban-board')
|
||||||
export class SimpleKanbanBoardController {
|
export class SimpleKanbanBoardController {
|
||||||
|
private logger = new Logger(SimpleKanbanBoardController.name);
|
||||||
private path: string;
|
private path: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -25,6 +28,7 @@ export class SimpleKanbanBoardController {
|
||||||
private issuesByTagsWidgetService: IssuesByTagsWidgetService,
|
private issuesByTagsWidgetService: IssuesByTagsWidgetService,
|
||||||
private redmineEventsGateway: RedmineEventsGateway,
|
private redmineEventsGateway: RedmineEventsGateway,
|
||||||
private listIssuesByFieldsWidgetService: ListIssuesByFieldsWidgetService,
|
private listIssuesByFieldsWidgetService: ListIssuesByFieldsWidgetService,
|
||||||
|
private issuesService: IssuesService,
|
||||||
) {
|
) {
|
||||||
this.path = this.configService.get<string>('simpleKanbanBoard.path');
|
this.path = this.configService.get<string>('simpleKanbanBoard.path');
|
||||||
}
|
}
|
||||||
|
|
@ -52,15 +56,11 @@ export class SimpleKanbanBoardController {
|
||||||
ext: 'jsonc',
|
ext: 'jsonc',
|
||||||
parser: parse,
|
parser: parse,
|
||||||
});
|
});
|
||||||
const issues = [] as number[];
|
const rootIssue = await this.issuesService.getIssueFromCache(
|
||||||
issues.push(cfg.rootIssueId);
|
cfg.rootIssueId,
|
||||||
if (cfg.groups) {
|
);
|
||||||
const groups = cfg.groups as RootIssueSubTreesWidgetNs.Models.GroupCfg;
|
const issues = await this.issuesService.getIssuesWithChildren(rootIssue);
|
||||||
groups.fromIssues.forEach((group) => {
|
this.logger.debug(`Issues for tree refresh - ${issues}`); // DEBUG
|
||||||
issues.push(group.issueId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.redmineEventsGateway.addIssues(issues);
|
|
||||||
return { success: true };
|
return { success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue