title: How to get total number of GitHub stars for a given repo in BigQuery?
body: <p>My goal is to track over time the popularity of my BigQuery repo.</p>
  
  <p>I want to use publicly available BigQuery datasets, like <a href="https://www.githubarchive.org/" rel="nofollow noreferrer">GitHub Archive</a> or <a href="https://cloud.google.com/bigquery/public-data/github" rel="nofollow noreferrer">the GitHub dataset</a></p>
  
  <p>The GitHub dataset <code>sample_repos</code> does not contain a snapshot of the star counts:</p>
  
  <pre><code>SELECT
    watch_count
  FROM
    [bigquery-public-data:github_repos.sample_repos]
  WHERE
    repo_name == 'angular/angular'
  </code></pre>
  
  <p>returns 5318.</p>
  
  <p>GitHub Archive is a timeline of event. I can try to sum them all, but the numbers do not match with the numbers in the GitHub UI. I guess because it does not count unstar actions. Here is the query I used:</p>
  
  <pre><code>SELECT
    COUNT(*)
  FROM
    [githubarchive:year.2011],
    [githubarchive:year.2012],
    [githubarchive:year.2013],
    [githubarchive:year.2014],
    [githubarchive:year.2015],
    [githubarchive:year.2016],
    TABLE_DATE_RANGE([githubarchive:day.], TIMESTAMP('2017-01-01'), TIMESTAMP('2017-03-30') )
  WHERE
    repo.name == 'angular/angular'
    AND type = "WatchEvent"
  </code></pre>
  
  <p>returns 24144</p>
  
  <p>The real value is 21,921</p>