mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 11:12:52 +00:00
refactor: create dedicated function for report
This commit is contained in:
@@ -292,7 +292,7 @@ export async function getMergeRequestsForProjects(api: Api,
|
|||||||
return projectMergeRequests;
|
return projectMergeRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function report(api: Api, label: string) {
|
export async function generateReport(api: Api, label: string): Promise<string> {
|
||||||
const templates = compileTemplates();
|
const templates = compileTemplates();
|
||||||
|
|
||||||
const groupIds: number[] = [];
|
const groupIds: number[] = [];
|
||||||
@@ -309,14 +309,12 @@ export async function report(api: Api, label: string) {
|
|||||||
const issueBranches = await getIdsOfIssuesWithBranchesForProjects(api, projects);
|
const issueBranches = await getIdsOfIssuesWithBranchesForProjects(api, projects);
|
||||||
const mergeRequests = await getMergeRequestsForProjects(api, projects);
|
const mergeRequests = await getMergeRequestsForProjects(api, projects);
|
||||||
|
|
||||||
const meetingDay = getNextMeetingDay();
|
let markdown = templates.header();
|
||||||
|
|
||||||
let allMarkdown = templates.header();
|
|
||||||
|
|
||||||
Object.keys(issuesGroupedByAssignee).forEach((_assigneeId) => {
|
Object.keys(issuesGroupedByAssignee).forEach((_assigneeId) => {
|
||||||
const assigneeId = parseInt(_assigneeId, 10);
|
const assigneeId = parseInt(_assigneeId, 10);
|
||||||
|
|
||||||
allMarkdown += templates.assigneeHeader(issuesGroupedByAssignee[assigneeId]);
|
markdown += templates.assigneeHeader(issuesGroupedByAssignee[assigneeId]);
|
||||||
|
|
||||||
issuesGroupedByAssignee[assigneeId].issues.sort((a, b) => {
|
issuesGroupedByAssignee[assigneeId].issues.sort((a, b) => {
|
||||||
let weightA = 0;
|
let weightA = 0;
|
||||||
@@ -342,7 +340,7 @@ export async function report(api: Api, label: string) {
|
|||||||
|
|
||||||
return weightB - weightA;
|
return weightB - weightA;
|
||||||
}).forEach((issue) => {
|
}).forEach((issue) => {
|
||||||
allMarkdown += issueToString(
|
markdown += issueToString(
|
||||||
issue,
|
issue,
|
||||||
issueBranches,
|
issueBranches,
|
||||||
mergeRequests,
|
mergeRequests,
|
||||||
@@ -350,16 +348,24 @@ export async function report(api: Api, label: string) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
allMarkdown += templates.assigneeFooter(issuesGroupedByAssignee[assigneeId]);
|
markdown += templates.assigneeFooter(issuesGroupedByAssignee[assigneeId]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return markdown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function report(api: Api, label: string) {
|
||||||
|
const meetingDay = getNextMeetingDay();
|
||||||
|
|
||||||
|
const markdown = generateReport(api, label);
|
||||||
|
|
||||||
let filename = join(cwd(), 'reports', meetingDay + '.md');
|
let filename = join(cwd(), 'reports', meetingDay + '.md');
|
||||||
|
|
||||||
if (label !== 'meeting') {
|
if (label !== 'meeting') {
|
||||||
filename = join(cwd(), 'reports', 'label.md');
|
filename = join(cwd(), 'reports', `${label}.md`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await asyncWriteFile(filename, allMarkdown);
|
await asyncWriteFile(filename, markdown);
|
||||||
|
|
||||||
logger.ok('Wrote file `' + filename + '`.');
|
logger.ok(`Wrote file '${filename}'.`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user