Skip to content

Instantly share code, notes, and snippets.

SELECT *
FROM [bigquery-public-data:github_repos.contents]
WHERE id IN (SELECT id FROM (
SELECT *
FROM [bigquery-public-data:github_repos.files]
WHERE path = 'package.json'
AND ref = 'refs/heads/master'
))
// The UDF
function getTasks(row, emit) {
if (row.jsonScripts) {
x = JSON.parse(row.jsonScripts)
if (x !== null && typeof x === 'object') {
tasksCounter = 0
Object.keys(x).forEach(function(entry) {
if (validTask(x, entry)) {
tasksCounter++;
}
SELECT tasksCounter, (count(distinct projectID) / 286140 * 100) as percent
FROM [scripts]
GROUP BY tasksCounter
ORDER BY tasksCounter
SELECT taskName, (count(*) / 974274 * 100) as percent
FROM [scripts]
GROUP BY taskName
ORDER BY percent DESC
SELECT task, (count(distinct projectID) / 974274 * 100) as percent
FROM [scripts]
GROUP BY task
ORDER BY percent DESC
SELECT scripts.taskType as taskType, scripts.percent as percent, types.group as type
FROM (
SELECT taskType, (count(distinct projectID) / 286140 * 100) as percent
FROM
(SELECT *, 'nodemon' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bnodemon\b)')),
(SELECT *, 'pm2' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bpm2\b)')),
(SELECT *, 'istanbul' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bistanbul\b)')),
(SELECT *, 'jsdoc' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bjsdoc\b)')),
(SELECT *, 'documentation' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bdocumentation\b)')),
(SELECT *, 'make' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bmake\b)')),
SELECT scripts.taskType as taskType, scripts.percent as percent, types.group as type
FROM (
SELECT taskType, (count(distinct projectID) / 6689 * 100) as percent
FROM
(SELECT *, 'nodemon' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bnodemon\b)')),
(SELECT *, 'pm2' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bpm2\b)')),
(SELECT *, 'istanbul' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bistanbul\b)')),
(SELECT *, 'jsdoc' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bjsdoc\b)')),
(SELECT *, 'documentation' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bdocumentation\b)')),
(SELECT *, 'make' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bmake\b)')),
SELECT scripts.taskType as taskType, scripts.percent as percent, types.group as type
FROM (
SELECT taskType, (count(distinct projectID) / 202808 * 100) as percent
FROM
(SELECT *, 'nodemon' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bnodemon\b)')),
(SELECT *, 'pm2' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bpm2\b)')),
(SELECT *, 'istanbul' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bistanbul\b)')),
(SELECT *, 'jsdoc' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bjsdoc\b)')),
(SELECT *, 'documentation' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bdocumentation\b)')),
(SELECT *, 'make' as taskType FROM [scripts] where REGEXP_MATCH(task, r'(\bmake\b)')),
SELECT task, (count(distinct projectID) / 202808 * 100) as percent
FROM [scripts]
WHERE taskName = 'test'
GROUP BY task
ORDER BY percent DESC
SELECT task, (count(distinct projectID) / 107646 * 100) as percent
FROM [scripts]
WHERE taskName = 'start'
GROUP BY task
ORDER BY percent DESC