为什么 Github Archive on Big Query 中的分叉数与 UI 不匹配?
Why does the number of forks in Github Archive on Big Query not match the UI?
我正在尝试通过 Big Query(doc here) 在 Github 存档中获取各种 Github 回购指标。但是,当我尝试计算分叉数时,我得到的数字与 Github UI 中指定的分叉数有很大不同。例如,当我 运行 这个 sql 脚本时:
SELECT repo.url,repo.name , COUNT(*) fork_count,
FROM [githubarchive:year.2011],
[githubarchive:year.2012],
[githubarchive:year.2013],
[githubarchive:year.2014],
[githubarchive:year.2015],
[githubarchive:year.2016],
[githubarchive:year.2017],
[githubarchive:year.2018],
[githubarchive:month.201901]
WHERE type='ForkEvent'
and repo.url like 'https://github.com/python/cpython'
GROUP BY 1,2
我得到的结果是:
Row repo_url repo_name fork_count
1 https://github.com/python/cpython cpython 177
然而,当我转到 URL 'https://github.com/python/cpython' 时,我看到有 8,198 个叉子。造成这种差异的原因是什么?
编辑:
Felipe 在下面指出,同一个回购可能有多个 URL。
然而,即使有多个 URLS,这个数字也不是与 UI 完全匹配的,而且这次比 UI 的数字大得多。有没有办法得到精确匹配?
您要查询什么?请注意,您会得到不同的结果,具体取决于您是选择存储库 ID、名称还是 url:
#standardSQL
SELECT repo.name, repo.id, repo.url, COUNT(*) c
FROM `githubarchive.month.201*`
WHERE type='ForkEvent'
AND (
repo.id = 81598961
OR repo.name='python/cpython'
OR repo.url like 'https://github.com/python/cpython'
)
GROUP BY 1,2,3
如果你想知道"when?":
#standardSQL
SELECT repo.name, repo.id, repo.url, COUNT(*) c
, MIN(DATE(created_at)) since, MAX(DATE(created_at)) until
FROM `githubarchive.month.201*`
WHERE type='ForkEvent'
AND (
repo.id = 81598961
OR repo.name='python/cpython'
OR repo.url like 'https://github.com/python/cpython'
)
GROUP BY 1,2,3
ORDER BY since
编辑:
GitHub 只列出每个用户一个分支 - 所以如果你想删除重复项,请执行 COUNT(DISTINCT actor.id) ,这会将它降低到 ~9k。
我正在尝试通过 Big Query(doc here) 在 Github 存档中获取各种 Github 回购指标。但是,当我尝试计算分叉数时,我得到的数字与 Github UI 中指定的分叉数有很大不同。例如,当我 运行 这个 sql 脚本时:
SELECT repo.url,repo.name , COUNT(*) fork_count,
FROM [githubarchive:year.2011],
[githubarchive:year.2012],
[githubarchive:year.2013],
[githubarchive:year.2014],
[githubarchive:year.2015],
[githubarchive:year.2016],
[githubarchive:year.2017],
[githubarchive:year.2018],
[githubarchive:month.201901]
WHERE type='ForkEvent'
and repo.url like 'https://github.com/python/cpython'
GROUP BY 1,2
我得到的结果是:
Row repo_url repo_name fork_count
1 https://github.com/python/cpython cpython 177
然而,当我转到 URL 'https://github.com/python/cpython' 时,我看到有 8,198 个叉子。造成这种差异的原因是什么?
编辑:
Felipe 在下面指出,同一个回购可能有多个 URL。
然而,即使有多个 URLS,这个数字也不是与 UI 完全匹配的,而且这次比 UI 的数字大得多。有没有办法得到精确匹配?
您要查询什么?请注意,您会得到不同的结果,具体取决于您是选择存储库 ID、名称还是 url:
#standardSQL
SELECT repo.name, repo.id, repo.url, COUNT(*) c
FROM `githubarchive.month.201*`
WHERE type='ForkEvent'
AND (
repo.id = 81598961
OR repo.name='python/cpython'
OR repo.url like 'https://github.com/python/cpython'
)
GROUP BY 1,2,3
如果你想知道"when?":
#standardSQL
SELECT repo.name, repo.id, repo.url, COUNT(*) c
, MIN(DATE(created_at)) since, MAX(DATE(created_at)) until
FROM `githubarchive.month.201*`
WHERE type='ForkEvent'
AND (
repo.id = 81598961
OR repo.name='python/cpython'
OR repo.url like 'https://github.com/python/cpython'
)
GROUP BY 1,2,3
ORDER BY since
编辑:
GitHub 只列出每个用户一个分支 - 所以如果你想删除重复项,请执行 COUNT(DISTINCT actor.id) ,这会将它降低到 ~9k。