mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-09 19:22:51 +00:00
feat: only unlabel closed issues before last meeting
This commit is contained in:
@@ -16,6 +16,7 @@ import {asyncPool} from '@krlwlfrt/async-pool';
|
||||
import {Api} from '@openstapps/gitlab-api';
|
||||
import {IssueState, Scope} from '@openstapps/gitlab-api/lib/types';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import * as moment from 'moment';
|
||||
import {flatten2dArray} from '../common';
|
||||
import {CONCURRENCY, GROUPS, NOTE_PREFIX} from '../configuration';
|
||||
|
||||
@@ -36,17 +37,31 @@ export async function unlabel(api: Api) {
|
||||
|
||||
Logger.log(`Fetched ${issues.length} closed issue(s).`);
|
||||
|
||||
await asyncPool(CONCURRENCY, issues, async (issue) => {
|
||||
if (issue.labels.indexOf('meeting') >= 0) {
|
||||
Logger.info(`Issue ${issue.title} is closed and has label "meeting". Removing it.`);
|
||||
const thisWeeksWednesday = moment()
|
||||
.startOf('week')
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
.hour(10)
|
||||
// tslint:disable-next-line:no-magic-numbers
|
||||
.day(3);
|
||||
|
||||
await api.createNote(
|
||||
issue.project_id,
|
||||
Scope.ISSUES,
|
||||
issue.iid,
|
||||
`${NOTE_PREFIX} Removed label \`meeting\` automatically.
|
||||
const lastWeeksWednesday = moment(thisWeeksWednesday)
|
||||
.subtract(1, 'week');
|
||||
|
||||
await asyncPool(CONCURRENCY, issues, async (issue) => {
|
||||
if (issue.labels.indexOf('meeting') >= 0 && issue.closed_at !== null) {
|
||||
|
||||
if (moment(issue.closed_at)
|
||||
.isBefore(lastWeeksWednesday)) {
|
||||
Logger.info(`Issue ${issue.title} is closed before last meeting and has label "meeting". Removing it.`);
|
||||
|
||||
await api.createNote(
|
||||
issue.project_id,
|
||||
Scope.ISSUES,
|
||||
issue.iid,
|
||||
`${NOTE_PREFIX} Removed label \`meeting\` automatically.
|
||||
/unlabel ~meeting`,
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user