Skip to content

Commit

Permalink
Merge pull request #1 from stackql/feature/notebook-updates
Browse files Browse the repository at this point in the history
Feature/notebook updates
  • Loading branch information
jeffreyaven authored Oct 27, 2023
2 parents db0fbc1 + e2dd32f commit 06cb105
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 98 deletions.
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

0 comments on commit 06cb105

Please sign in to comment.