mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2025-12-13 17:56:20 +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;
|
||||
}
|
||||
|
||||
export async function report(api: Api, label: string) {
|
||||
export async function generateReport(api: Api, label: string): Promise<string> {
|
||||
const templates = compileTemplates();
|
||||
|
||||
const groupIds: number[] = [];
|
||||
@@ -309,14 +309,12 @@ export async function report(api: Api, label: string) {
|
||||
const issueBranches = await getIdsOfIssuesWithBranchesForProjects(api, projects);
|
||||
const mergeRequests = await getMergeRequestsForProjects(api, projects);
|
||||
|
||||
const meetingDay = getNextMeetingDay();
|
||||
|
||||
let allMarkdown = templates.header();
|
||||
let markdown = templates.header();
|
||||
|
||||
Object.keys(issuesGroupedByAssignee).forEach((_assigneeId) => {
|
||||
const assigneeId = parseInt(_assigneeId, 10);
|
||||
|
||||
allMarkdown += templates.assigneeHeader(issuesGroupedByAssignee[assigneeId]);
|
||||
markdown += templates.assigneeHeader(issuesGroupedByAssignee[assigneeId]);
|
||||
|
||||
issuesGroupedByAssignee[assigneeId].issues.sort((a, b) => {
|
||||
let weightA = 0;
|
||||
@@ -342,7 +340,7 @@ export async function report(api: Api, label: string) {
|
||||
|
||||
return weightB - weightA;
|
||||
}).forEach((issue) => {
|
||||
allMarkdown += issueToString(
|
||||
markdown += issueToString(
|
||||
issue,
|
||||
issueBranches,
|
||||
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');
|
||||
|
||||
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