mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 09:03:02 +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 {Api} from '@openstapps/gitlab-api';
|
||||||
import {IssueState, Scope} from '@openstapps/gitlab-api/lib/types';
|
import {IssueState, Scope} from '@openstapps/gitlab-api/lib/types';
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
|
import * as moment from 'moment';
|
||||||
import {flatten2dArray} from '../common';
|
import {flatten2dArray} from '../common';
|
||||||
import {CONCURRENCY, GROUPS, NOTE_PREFIX} from '../configuration';
|
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).`);
|
Logger.log(`Fetched ${issues.length} closed issue(s).`);
|
||||||
|
|
||||||
await asyncPool(CONCURRENCY, issues, async (issue) => {
|
const thisWeeksWednesday = moment()
|
||||||
if (issue.labels.indexOf('meeting') >= 0) {
|
.startOf('week')
|
||||||
Logger.info(`Issue ${issue.title} is closed and has label "meeting". Removing it.`);
|
// tslint:disable-next-line:no-magic-numbers
|
||||||
|
.hour(10)
|
||||||
|
// tslint:disable-next-line:no-magic-numbers
|
||||||
|
.day(3);
|
||||||
|
|
||||||
await api.createNote(
|
const lastWeeksWednesday = moment(thisWeeksWednesday)
|
||||||
issue.project_id,
|
.subtract(1, 'week');
|
||||||
Scope.ISSUES,
|
|
||||||
issue.iid,
|
await asyncPool(CONCURRENCY, issues, async (issue) => {
|
||||||
`${NOTE_PREFIX} Removed label \`meeting\` automatically.
|
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`,
|
/unlabel ~meeting`,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user