Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Atomist command to find out who is reviewing
import { commandHandlerFrom } from "@atomist/automation-client/onCommand";
import { HandleCommand } from "@atomist/automation-client";
import { Parameters } from "@atomist/automation-client/decorators";
import * as _ from "lodash"
@Parameters()
export class WhoIsBusyParameters {
}
export const whoIsBusyCommand: HandleCommand<any> = commandHandlerFrom(
async (ctx) => {
await ctx.messageClient.respond("I hear you");
const result: any = await ctx.graphClient.executeQuery(`query K {
PullRequest {
number
repo @required {
owner name
}
reviewers @required {
login
person {
chatId
{
screenName
}
}
}
}
}
`);
const allReviewers = _.flatten(result.PullRequest.map(r => r.reviewers))
const reviewersByLogin = _.groupBy(allReviewers,(r: any) => _.get(r, "person.chatId.screenName", r.login));
const lines = Object.keys(reviewersByLogin).map(login =>
`${login} has ${reviewersByLogin[login].length} review in process`);
return ctx.messageClient.respond(lines.join("\n"))
}, WhoIsBusyParameters,
"WhoIsBusy", "Peter", "who is busy"
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.