Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit cc4c10f

Browse files
authored
Adding /clear-land-when-able-queue API (#86)
* Adding /clear-land-when-able-queue API to avoid PR stalling in this queue * Replacing Landkid by Luke's && not fix Co-authored-by: raja <[email protected]>
1 parent 0140a52 commit cc4c10f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/lib/Runner.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,16 @@ export class Runner {
616616
await PullRequest.truncate();
617617
};
618618

619+
clearLandWhenAbleQueue = async () => {
620+
const awaitingRequests = await this.queue.getStatusesForWaitingRequests();
621+
for (const status of awaitingRequests) {
622+
await status.request.setStatus(
623+
'aborted',
624+
'Removed from land-when-able-queue manually by admin',
625+
);
626+
}
627+
};
628+
619629
getState = async (requestingUser: ISessionUser): Promise<RunnerState> => {
620630
const requestingUserMode = await permissionService.getPermissionForUser(requestingUser.aaid);
621631
const [

src/routes/api/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ export function apiRoutes(runner: Runner, client: BitbucketClient, config: Confi
250250

251251
const landRequest: LandRequestOptions = {
252252
prId,
253-
triggererAaid: req.user ? req.user.aaid : 'landkid',
253+
// Must always have a valid aaid, so lets set it to Luke's aaid
254+
triggererAaid: req.user ? req.user.aaid : '557057:9512f4e4-3319-4d30-a78d-7d5f8ed243ae',
254255
commit: prInfo.commit,
255256
prTitle: prInfo.title,
256257
prAuthorAaid: prInfo.authorAaid,
@@ -278,6 +279,20 @@ export function apiRoutes(runner: Runner, client: BitbucketClient, config: Confi
278279
}),
279280
);
280281

282+
router.delete(
283+
'/clear-land-when-able-queue',
284+
requireAuth('admin'),
285+
wrap(async (req, res) => {
286+
Logger.verbose('Deleting land-when-able queue', {
287+
namespace: 'routes:api:clear-land-when-able-queue',
288+
});
289+
await runner.clearLandWhenAbleQueue();
290+
res.json({
291+
response: 'You may not be a threat, but you better stop pretending to be a hero... Done!',
292+
});
293+
}),
294+
);
295+
281296
router.post(
282297
'/to-the-top/:id',
283298
requireAuth('admin'),

0 commit comments

Comments
 (0)