mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
feat: add max depth for reminders
This commit is contained in:
@@ -191,3 +191,8 @@ export const SLACK_CHANNEL = 'C762UG76Z';
|
|||||||
* Concurrency for async pool
|
* Concurrency for async pool
|
||||||
*/
|
*/
|
||||||
export const CONCURRENCY = 3;
|
export const CONCURRENCY = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum depth for merge request reminders
|
||||||
|
*/
|
||||||
|
export const MAX_DEPTH_FOR_REMINDER = 2;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
} from '@openstapps/gitlab-api/lib/types';
|
} from '@openstapps/gitlab-api/lib/types';
|
||||||
import {Logger} from '@openstapps/logger';
|
import {Logger} from '@openstapps/logger';
|
||||||
import {WebClient} from '@slack/client';
|
import {WebClient} from '@slack/client';
|
||||||
import {CONCURRENCY, GROUPS, NOTE_PREFIX, SLACK_CHANNEL} from '../configuration';
|
import {CONCURRENCY, GROUPS, MAX_DEPTH_FOR_REMINDER, NOTE_PREFIX, SLACK_CHANNEL} from '../configuration';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remind people of open merge requests
|
* Remind people of open merge requests
|
||||||
@@ -33,7 +33,20 @@ import {CONCURRENCY, GROUPS, NOTE_PREFIX, SLACK_CHANNEL} from '../configuration'
|
|||||||
*/
|
*/
|
||||||
export async function remind(api: Api): Promise<void> {
|
export async function remind(api: Api): Promise<void> {
|
||||||
// get list of open merge requests
|
// get list of open merge requests
|
||||||
const mergeRequests = await api.getMergeRequests(MembershipScope.GROUPS, GROUPS[0], MergeRequestState.OPENED);
|
const allMergeRequests = await api
|
||||||
|
.getMergeRequests(MembershipScope.GROUPS, GROUPS[0], MergeRequestState.OPENED);
|
||||||
|
|
||||||
|
const mergeRequests = allMergeRequests.filter((mergeRequest) => {
|
||||||
|
const parts = mergeRequest.web_url.split('/');
|
||||||
|
|
||||||
|
// remove protocol, server name and main group
|
||||||
|
parts.splice(0, parts.indexOf('gitlab.com') + 1 + 1);
|
||||||
|
|
||||||
|
// remove merge_requests and INDEX parts
|
||||||
|
parts.splice(parts.length - 1 - 1);
|
||||||
|
|
||||||
|
return parts.length <= MAX_DEPTH_FOR_REMINDER;
|
||||||
|
});
|
||||||
|
|
||||||
Logger.info(`Found ${mergeRequests.length} open merge requests.`);
|
Logger.info(`Found ${mergeRequests.length} open merge requests.`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user