mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-09 18:32:49 +00:00
refactor: change move to unlabel
This commit is contained in:
47
src/tasks/unlabel.ts
Normal file
47
src/tasks/unlabel.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import {Api} from '@openstapps/gitlab-api';
|
||||
import {asyncPool} from 'async-pool-native/dist/async-pool';
|
||||
import {flatten2dArray, logger} from '../common';
|
||||
import {GROUPS, NOTE_PREFIX} from '../configuration';
|
||||
|
||||
/**
|
||||
* Remove label `meeting` from closed issues
|
||||
*
|
||||
* @param api Instance of GitLabAPI to send requests with
|
||||
*/
|
||||
export async function unlabel(api: Api) {
|
||||
const issueResults = await asyncPool(3, GROUPS, (groupId) => {
|
||||
return api.getIssues({
|
||||
groupId: groupId,
|
||||
state: 'closed',
|
||||
});
|
||||
});
|
||||
|
||||
const issues = flatten2dArray(issueResults);
|
||||
|
||||
logger.log('Fetched ' + issues.length + ' closed issue(s).');
|
||||
|
||||
await asyncPool(1, issues, async (issue) => {
|
||||
await api.createNote(
|
||||
issue.project_id,
|
||||
issue.iid,
|
||||
`${NOTE_PREFIX} Removed label \`meeting\` automatically.
|
||||
/unlabel ~meeting`,
|
||||
);
|
||||
});
|
||||
|
||||
logger.ok('Label `meeting` has been removed from closed issues.');
|
||||
}
|
||||
Reference in New Issue
Block a user