Skip to content

Instantly share code, notes, and snippets.

@jlewi
Created December 25, 2021 21:01
Show Gist options
  • Save jlewi/759527e1bcfa6713a8fc07efbe601103 to your computer and use it in GitHub Desktop.
Save jlewi/759527e1bcfa6713a8fc07efbe601103 to your computer and use it in GitHub Desktop.
BigQuery to find Google Docs In issues
SELECT
IF
(type="IssueCommentEvent",
REGEXP_EXTRACT(json_value(payload,
"$.comment.body"), "docs.google.com/document/d/[0-9a-zA-Z_-]*"),
REGEXP_EXTRACT(json_value(payload,
"$.issue.body"), "docs.google.com/document/d/[0-9a-zA-Z_-]*") ) AS doc,
json_value(payload,
"$.issue.html_url") AS issue_url,
IF
(type="IssueCommentEvent",
json_value(payload,
"$.comment.html_url"),
"") AS comment_url
FROM
`githubarchive.month.2021*`
WHERE
(type="IssuesEvent"
OR type="IssueCommentEvent")
AND STARTS_WITH(repo.url, "https://api.github.com/repos/kubernetes")
AND ((type="IssueCommentEvent"
AND contains_SUBSTR(json_value(payload,
"$.comment.body"),
"docs.google.com/document"))
OR ( type="IssuesEvent"
AND contains_SUBSTR(json_value(payload,
"$.issue.body"),
"docs.google.com/document") ))
GROUP BY
doc,
issue_url,
comment_url
ORDER BY
issue_url,
comment_url,
doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment