Created
June 4, 2018 23:46
-
-
Save alexgleith/c1de496d76a00e8b173cb81526f72d8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"import requests" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import requests\n", | |
"import json\n", | |
"import datetime" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"User: walsh-andrew - 73, 94, 2\n", | |
"User: uchchwhash - 2575, 1162, 4\n", | |
"User: Kirill888 - 804, 315, 40\n", | |
"User: omad - 87, 65, 6\n" | |
] | |
} | |
], | |
"source": [ | |
"url = \"https://api.github.com/repos/opendatacube/datacube-core/stats/contributors\"\n", | |
"\n", | |
"response = requests.get(url)\n", | |
"\n", | |
"users = response.json()\n", | |
"\n", | |
"today = datetime.datetime.now()\n", | |
"one_month_ago = today - datetime.timedelta(days=30)\n", | |
"\n", | |
"user_data = {}\n", | |
"\n", | |
"for user in users:\n", | |
" name = user['author']['login']\n", | |
" a = 0\n", | |
" d = 0\n", | |
" c = 0\n", | |
" for row in user['weeks']:\n", | |
" week_start = datetime.datetime.fromtimestamp(row['w'])\n", | |
" \n", | |
" if week_start > one_month_ago:\n", | |
" a += row['a']\n", | |
" d += row['d']\n", | |
" c += row['c']\n", | |
"\n", | |
" data = [a, d, c]\n", | |
" if (a and d and c):\n", | |
" user_data[name] = data\n", | |
" \n", | |
"for user in user_data:\n", | |
" print(\"User: {} - {}, {}, {}\".format(user, *user_data[user]))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.6.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment