Skip to content

retreiving my issue activity¤

retreive my activity with the github graphql api.

construct the query from parameters¤

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

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)
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
      }
      }
    }
  }
}
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)
freq = df.groupby(pandas.Grouper(freq="1D", key="publishedAt")).count()

what days where these comments made at?

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
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