TheRenegadeCoder / sample-programs

Sample Programs in Every Programming Language
https://sampleprograms.io
MIT License
548 stars 563 forks source link

Create Analytics Includes #711

Closed jrg94 closed 5 years ago

jrg94 commented 6 years ago

I'd like to write up a handful of analytics files that we can use around the site to display data info. For instance, I'd like to be able to quickly calculate the following:

  1. The total number of articles in the repo {{ site.posts | size }}
  2. The total number of language articles {{ site.categories.language | size }}
  3. The total number of project articles {{ site.categories.project | size }}
  4. The total number of articles per language {{ site.tags.LANGUAGE | size }}

As well, as these! However, I'm not worried about these right now... they don't seem to be as easy as the first few.

  1. The total number of code snippets
  2. The total number of code snippets by language
  3. The total number of code snippets by project
  4. The total number of code snippets without an article

And, many more!

jrg94 commented 6 years ago

For the last four, I may need to play around with the GitHub API. Here's an example: https://api.github.com/users/therenegadecoder/repos

jrg94 commented 6 years ago

Apparently, we can query languages which is pretty sweet: https://api.github.com/repos/TheRenegadeCoder/sample-programs/languages

Here's the output:

{
  "C": 16259,
  "Python": 7227,
  "Java": 6453,
  "C#": 5558,
  "TypeScript": 5113,
  "Haskell": 4258,
  "Go": 3348,
  "Rust": 2959,
  "PowerShell": 2184,
  "JavaScript": 1417,
  "Shell": 1397,
  "C++": 1365,
  "Ruby": 1317,
  "Kotlin": 1314,
  "Swift": 1125,
  "Dockerfile": 965,
  "Visual Basic": 955,
  "Brainfuck": 820,
  "Vim script": 619,
  "TeX": 607,
  "Julia": 581,
  "Groovy": 501,
  "PHP": 474,
  "Perl": 423,
  "Crystal": 390,
  "Scala": 386,
  "D": 377,
  "OpenEdge ABL": 347,
  "Lua": 320,
  "Fortran": 282,
  "PicoLisp": 271,
  "NewLisp": 243,
  "Dart": 224,
  "Objective-C": 202,
  "Scheme": 173,
  "COBOL": 108,
  "Ada": 100,
  "Opa": 100,
  "Verilog": 99,
  "Elm": 92,
  "Erlang": 91,
  "Ballerina": 88,
  "Agda": 81,
  "Golo": 74,
  "Pony": 72,
  "Red": 57,
  "Roff": 54,
  "LOLCODE": 51,
  "Common Lisp": 49,
  "Matlab": 46,
  "Forth": 41,
  "ABAP": 37,
  "Racket": 34,
  "Smalltalk": 34,
  "Clojure": 33,
  "OCaml": 33,
  "Csound": 33,
  "AppleScript": 31,
  "Hack": 27,
  "Shen": 26,
  "Factor": 22,
  "Elixir": 22,
  "MoonScript": 22,
  "Nim": 21,
  "R": 21,
  "Tcl": 21,
  "Ring": 20,
  "REXX": 20
}
jrg94 commented 6 years ago

Also, it looks like we can explore the repo: https://api.github.com/repos/TheRenegadeCoder/sample-programs/contents/

jrg94 commented 6 years ago

Looks like we can even display issues which is cool: https://api.github.com/repos/TheRenegadeCoder/sample-programs/issues

jrg94 commented 6 years ago

The first 4 are silly, but I do want to look into the next four, so I'll keep this issue open.

jrg94 commented 5 years ago

Summary from #735:

Turns out we can use site.github but it has a couple drawbacks.

  1. No up to date querying -- the variable is static so the site will need to be rebuilt if information changes.
  2. Limited data -- lots of URLs with not a lot of opportunities to query them unfortunately.

That said, here's a nice example of the available liquid tags:

{% assign repos = site.github.public_repositories %}
{% for repo in repos %}
  {{ repo.full_name }}
{% endfor %}
jrg94 commented 5 years ago

I'd like to deal with this later. Let's get back to tackling existing work.