Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/notebook updates #1

Merged
merged 6 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "stackql-codespaces-demo",
"image": "stackql/stackql-codespaces-base",
"hostRequirements": {
"cpus": 2
"containerEnv": {
"STACKQL_GITHUB_PASSWORD": "${secrets:STACKQL_GITHUB_PASSWORD}",
"STACKQL_GITHUB_USERNAME": "${secrets:STACKQL_GITHUB_USERNAME}"
},
"hostRequirements": {
"cpus": 16
},
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -12,4 +15,4 @@
]
}
}
}
}
90 changes: 0 additions & 90 deletions .devcontainer/icon.svg

This file was deleted.

101 changes: 97 additions & 4 deletions notebooks/github.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Stargazers per Repo"
"## Top Stargazers per Repo"
]
},
{
Expand All @@ -49,10 +49,13 @@
"outputs": [],
"source": [
"%%stackql\n",
"select name, stargazers_count \n",
"select name, stargazers FROM\n",
"(select name, stargazers_count as stargazers\n",
"from github.repos.repos \n",
"where org = '$org' \n",
"order by stargazers_count desc"
"and visibility = 'public'\n",
"order by stargazers_count desc) t\n",
"limit 10"
]
},
{
Expand All @@ -63,7 +66,53 @@
},
"outputs": [],
"source": [
"_.plot(kind='bar', title='Stargazers', x='name', y='stargazers_count')"
"_.plot(kind='bar', title='Stargazers', x='name', y='stargazers');"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Daily Traffic Stats for `stackql`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%stackql\n",
"select \n",
"JSON_EXTRACT(json_each.value, '$$.count') as count,\n",
"JSON_EXTRACT(json_each.value, '$$.uniques') as uniques,\n",
"DATE(JSON_EXTRACT(json_each.value, '$$.timestamp')) as date\n",
"from github.repos.view_traffic, json_each(views) \n",
"WHERE owner = '$owner' AND repo = '$repo'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"df = stackql_df\n",
"fig, ax = plt.subplots(figsize=(10,6))\n",
"ax.bar(df['date'], df['count'], color='b', alpha=0.6, label='Count')\n",
"ax.plot(df['date'], df['uniques'], color='r', marker='o', label='Uniques')\n",
"\n",
"ax.set_xlabel('Date')\n",
"ax.set_ylabel('Value')\n",
"ax.set_xticks(df['date'])\n",
"ax.set_xticklabels(df['date'], rotation=45)\n",
"ax.legend()\n",
"\n",
"plt.title('Count and Uniques Over Time')\n",
"fig.tight_layout()\n",
"plt.show()"
]
},
{
Expand All @@ -87,6 +136,50 @@
"WHERE owner = '$owner' AND repo = '$repo'\n",
"AND s.login IS NULL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Org Followers who Arent Stargazers"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%stackql\n",
"SELECT f.login FROM \n",
"github.users.followers f\n",
"LEFT OUTER JOIN github.activity.repo_stargazers s\n",
"ON f.login = s.login\n",
"WHERE s.owner = '$owner' AND s.repo = '$repo' AND f.username = '$org'\n",
"AND s.login IS NULL"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Repo Watchers who Arent Stargazers"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%stackql\n",
"SELECT w.login FROM \n",
"github.activity.repo_watchers w\n",
"LEFT OUTER JOIN github.activity.repo_stargazers s\n",
"ON w.login = s.login\n",
"WHERE owner = '$owner' AND repo = '$repo'\n",
"AND s.login IS NULL"
]
}
],
"metadata": {
Expand Down