-- Says when you're asked to review a pull request, through gh. Toolshed runs it every 15 seconds, -- while it's turned on: GitHub can't push to a Mac, and a search that often uses a fraction of -- what GraphQL allows an hour. What's been said is remembered, so nothing is said twice; the first time -- it runs, what's there already is noted. local query = [[ query { search(query: "is:pr is:open review-requested:@me", type: ISSUE, first: 50) { nodes { ... on PullRequest { number title url repository { nameWithOwner } } } } }]] local seen = toolshed.memory() local first = seen == nil seen = seen or {} -- A failure ends this run; Toolshed runs it again a while later. local data = toolshed.json.decode(toolshed.exec({ "gh", "api", "graphql", "-f", "query=" .. query })).data local now = {} for _, pr in ipairs(data.search.nodes) do if pr.url then now[pr.url] = true if not first and not seen[pr.url] then local said = { repo = pr.repository.nameWithOwner, number = pr.number, title = pr.title } local data = { repo = pr.repository.nameWithOwner, number = tostring(math.floor(pr.number)), url = pr.url } toolshed.notify(toolshed.t("say.review", said), { tool = "pr", stay = true, actions = { { title = toolshed.t("action.web"), action = "web", data = data }, { title = toolshed.t("action.copy-url"), action = "copy-url", data = data }, } }) end end end toolshed.remember(now)