Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAI-14070/FAI-14071: Add use_board_ownership flag to Jira Source #1908

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ export class FarosIssues extends JiraConverter {
},
});

if (!this.useBoardOwnership(ctx)) {
matiaslcoulougian marked this conversation as resolved.
Show resolved Hide resolved
results.push({
model: 'tms_TaskBoardRelationship',
record: {
task: {uid: issue.key, source},
board: {uid: issue.project, source},
},
});
}

if (JiraCommon.normalize(issue.type) === 'epic') {
results.push({
model: 'tms_Epic',
Expand Down
4 changes: 4 additions & 0 deletions sources/jira-source/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export class JiraSource extends AirbyteSourceBase<JiraConfig> {
if (config.fetch_teams) {
streamNames.push(...TeamStreamNames);
}
// If board ownership not enabled, remove the board issues stream.
if (config.use_board_ownership === false) {
streamNames.splice(streamNames.indexOf('faros_board_issues'), 1);
}
const streams = catalog.streams.filter((stream) =>
streamNames.includes(stream.stream.name)
);
Expand Down
1 change: 1 addition & 0 deletions sources/jira-source/src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface JiraConfig extends AirbyteConfig, RoundRobinConfig {
readonly requestedStreams?: Set<string>;
readonly use_sprints_reverse_search?: boolean;
readonly use_faros_board_issue_tracker?: boolean;
readonly use_board_ownership?: boolean;
matiaslcoulougian marked this conversation as resolved.
Show resolved Hide resolved
readonly fetch_teams?: boolean;
readonly organization_id?: string;
readonly start_date?: string;
Expand Down
25 changes: 25 additions & 0 deletions sources/jira-source/src/project-board-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class ProjectBoardFilter {
// Ensure included / excluded boards are loaded
await this.loadSelectedBoards();

if (!this.useBoardOwnership()) {
matiaslcoulougian marked this conversation as resolved.
Show resolved Hide resolved
await this.getBoardsFromProjects();
}

if (this.isWebhookSupplementMode() && this.hasFarosClient()) {
await this.getBoardsFromFaros(jira);
} else {
Expand Down Expand Up @@ -214,6 +218,23 @@ export class ProjectBoardFilter {
}
}

/**
* Use the Jira API to get all boards for each project and use the UIDs to populate
* the internal boards map.
* Only includes boards based on the inclusion criteria determined by getBoardInclusion.
* With this method we generate a unique board per project to represent all tasks in the project
*
* @returns A Promise that resolves when all boards have been processed.
*/
private async getBoardsFromProjects(): Promise<void> {
for (const project of this.projects) {
const {included, issueSync} = await this.getBoardInclusion(project);
matiaslcoulougian marked this conversation as resolved.
Show resolved Hide resolved
if (included) {
this.boards.set(project, {uid: project, issueSync});
}
}
}

private async loadSelectedBoards(): Promise<void> {
if (this.loadedSelectedBoards) {
return;
Expand Down Expand Up @@ -251,4 +272,8 @@ export class ProjectBoardFilter {
private hasFarosClient(): boolean {
return Boolean(this.farosClient);
}

private useBoardOwnership(): boolean {
return this.config.use_board_ownership ?? true;
}
}
16 changes: 16 additions & 0 deletions sources/jira-source/src/streams/faros_boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ export class FarosBoards extends StreamWithProjectSlices {
const jira = await Jira.instance(this.config, this.logger);
const projectKey = streamSlice?.project;

// If board ownership is disabled, return a virtual board for all tasks in the project.
if (this.config.use_board_ownership === false) {
const {included, issueSync} =
await this.projectBoardFilter.getBoardInclusion(projectKey);
if (included) {
yield {
uid: projectKey,
name: `Tasks in project ${projectKey}`,
projectKey,
type: 'Custom',
issueSync,
};
}
return;
}

matiaslcoulougian marked this conversation as resolved.
Show resolved Hide resolved
// Virtual board to represent all tasks in the project without a board
yield {
uid: `faros-tasks-with-no-board-${projectKey}`,
Expand Down