skip to main content

@tonyfast s notebooks

site navigation
notebook summary
title
retreiving my issue activity
description
retreive my activity with the github graphql api.
cells
11 total
8 code
state
executed in order
kernel
pidgy
language
markdown
name
pidgy
lines of code
45
outputs
8
table of contents
{"kernelspec": {"display_name": "pidgy", "language": "markdown", "name": "pidgy"}, "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.9.13"}, "title": "retreiving my issue activity", "description": "retreive my activity with the github graphql api."}
notebook toolbar
Activate
cell ordering
1

retreiving my issue activity

retreive my activity with the github graphql api.

2
3

construct the query from parameters

we use % string formatting because of the braces in graphql syntaxes.

4 1 outputs.
def get_stamps(user="tonyfast", repo="iota-school/notebooks-for-all"):
    return \

query { search(type:ISSUE, query: "user:%s repo:%s", first: 100) { edges { node { ... on Issue { url } ... on PullRequest { url } ... on Comment { publishedAt } } } } }\

        % (user, repo)
5 1 outputs.
a graphql query the find the dates a user made comments on issues or pull requests.
query { 
  search(type:ISSUE, query: "user:tonyfast repo:iota-school/notebooks-for-all", first: 100) {
    edges {
      node {
      ... on Issue {
        url
      }
       ... on PullRequest {
        url
      }
      ... on Comment {
        publishedAt
      }
      }
    }
  }
}
6 1 outputs.
df = pandas.DataFrame((
    response := requests.post("https://api.github.com/graphql", json=dict(query=get_stamps()), **header)
).json()["data"]["search"]["edges"])["node"].apply(pandas.Series)
df.publishedAt = df.publishedAt.pipe(pandas.to_datetime)
7 1 outputs.
freq = df.groupby(pandas.Grouper(freq="1D", key="publishedAt")).count()
8

what days where these comments made at?

9 2 outputs.
url
publishedAt
2015-08-07 00:00:00+00:00 1.0
2016-01-02 00:00:00+00:00 2.0
2016-01-03 00:00:00+00:00 3.0
2016-01-11 00:00:00+00:00 1.0
2016-01-23 00:00:00+00:00 1.0
... ...
2022-11-08 00:00:00+00:00 2.0
2022-11-16 00:00:00+00:00 1.0
2022-11-21 00:00:00+00:00 1.0
2022-11-22 00:00:00+00:00 1.0
2022-12-14 00:00:00+00:00 1.0

64 rows × 1 columns

days = freq[freq.astype(bool)].dropna()
days
10 2 outputs.
url
publishedAt
2015-08-07 00:00:00+00:00 1.0
2016-01-02 00:00:00+00:00 2.0
2016-01-03 00:00:00+00:00 3.0
2016-01-11 00:00:00+00:00 1.0
2016-01-23 00:00:00+00:00 1.0
... ...
2022-11-08 00:00:00+00:00 2.0
2022-11-16 00:00:00+00:00 1.0
2022-11-21 00:00:00+00:00 1.0
2022-11-22 00:00:00+00:00 1.0
2022-12-14 00:00:00+00:00 1.0

64 rows × 1 columns

days
11