{"id":14063171,"url":"https://github.com/yonicd/tidyghql","last_synced_at":"2026-03-06T09:31:33.661Z","repository":{"id":91010950,"uuid":"143933458","full_name":"yonicd/tidyghql","owner":"yonicd","description":"create tidy outputs of open github issues and prs using graphql","archived":false,"fork":false,"pushed_at":"2018-08-08T00:20:45.000Z","size":13,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T15:11:27.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yonicd.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-07T22:34:57.000Z","updated_at":"2020-12-04T16:37:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"a467d2af-ed4f-45e1-9d38-166d04b35dc7","html_url":"https://github.com/yonicd/tidyghql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yonicd/tidyghql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonicd%2Ftidyghql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonicd%2Ftidyghql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonicd%2Ftidyghql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonicd%2Ftidyghql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yonicd","download_url":"https://codeload.github.com/yonicd/tidyghql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yonicd%2Ftidyghql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30168971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:03:06.739Z","updated_at":"2026-03-06T09:31:33.628Z","avatar_url":"https://github.com/yonicd.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"---\noutput: github_document\nalways_allow_html: yes\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"tools/readme/README-\"\n)\n```\n\n# `ghql`\n\nUsing a quick query language to pull multiple api requests at once.\n\n  * [installation](#install-ghql)\n  * [tidy function](#tidy-issues)\n  * [using with github](#working-with-github)\n\n## Install ghql\n\n```{r install, eval = FALSE}\n\nremotes::install_github(\"ropensci/ghql\")\n\n```\n\n```{r}\nlibrary(magrittr)\n```\n\n## Query Objects\n\nopen a new query object\n\n```{r remedy001}\n\nqry \u003c- ghql::Query$new()\n\n```\n\ndefine the grapql query\n\n```{r remedy002}\n\nqry$query('user_states','{\n          viewer {\n    repositories(privacy:PUBLIC,first: 30) {\n      pageInfo {\n        hasNextPage\n        endCursor\n      }\n      edges {\n        node {\n          name\n          pullRequests(states:[OPEN],last: 20, orderBy: {field: CREATED_AT, direction: DESC}) {\n      \t\tedges {\n            node {\n              title\n              number\n              state\n              createdAt\n              author{\n                login\n              }\n            \t}\n      \t\t\t}\n    \t\t\t}\n          issues(states:[OPEN],last: 20, orderBy: {field: CREATED_AT, direction: DESC}) {\n      \t\tedges {\n            node {\n              title\n              number\n              state\n              createdAt\n              author{\n                login\n              }\n            \t}\n      \t\t\t}\n    \t\t\t}\n        }\n      }\n    }\n  }\n}')\n\n```\n\n## tidy issues\n\n```{r remedy003}\n\ntidy_issues \u003c- function(x){\n  \n  x1 \u003c- jsonlite::fromJSON(x)\n  \n  edges \u003c- purrr::transpose(x1$data$viewer$repositories$edges)%\u003e%\n    dplyr::as_tibble()\n  \n  open_edges \u003c- edges%\u003e%\n    dplyr::select(name,pullRequests)%\u003e%\n    tidyr::unnest()%\u003e%\n    dplyr::rename(open_pullRequests = edges)%\u003e%\n    dplyr::left_join(\n      edges%\u003e%\n        dplyr::select(name,issues)%\u003e%\n        tidyr::unnest()%\u003e%\n        dplyr::rename(open_issues = edges),\n      by='name'\n    )\n \n  PR \u003c- purrr::transpose(open_edges$open_pullRequests)%\u003e%\n    purrr::flatten()%\u003e%\n    purrr::set_names(open_edges$name)%\u003e%\n    purrr::discard(.p = is.null)%\u003e%\n    purrr::map_df(.f=function(x) {\n      x$author \u003c- purrr::flatten_chr(x$author)\n      x},.id = 'repository')%\u003e%\n    dplyr::mutate(type = 'pull_request')%\u003e%\n    dplyr::select(-state)\n  \n  ISSUES \u003c- purrr::transpose(open_edges$open_issues)%\u003e%\n    purrr::flatten()%\u003e%\n    purrr::set_names(open_edges$name)%\u003e%\n    purrr::discard(.p = is.null)%\u003e%\n    purrr::map_df(.f=function(x) {\n      x$author \u003c- purrr::flatten_chr(x$author)\n      x},.id = 'repository')%\u003e%\n    dplyr::mutate(type = 'issue')%\u003e%\n    dplyr::select(-state)\n\n  output \u003c- dplyr::bind_rows(PR,ISSUES)\n  \n  output$createdAt = as.POSIXct(output$createdAt, \"UTC\", \"%Y-%m-%dT%H:%M:%S\")\n  output$days_passed = as.numeric(difftime(Sys.time(),output$createdAt,units = 'days'))\n  \n  output\n  \n}\n\n```\n\n## Working with Github\n\nload gh client with GITHUB_PAT\n\n```{r remedy004}\n  \n    cli_gh \u003c- ghql::GraphqlClient$new(\n      url = \"https://api.github.com/graphql\",\n      headers = httr::add_headers(Authorization = sprintf(\"Bearer %s\", Sys.getenv(\"GITHUB_PAT\")))\n    )\n\n```\n\nload the schema\n\n```{r remedy005}\n  \ncli_gh$load_schema()\n\n```\n\nexecute the graphql query\n\n```{r remedy006}\n  \nx_gh \u003c- cli_gh$exec(qry$queries$user_states)       \n\n```\n\ntidy up\n\n```{r remedy007}\n  \noutput \u003c- tidy_issues(x_gh)\n\n```\n\n```{r}\noutput%\u003e%\n  dplyr::glimpse()\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e \u003cspan title='Click to Expand'\u003e Pull Request Table \u003c/span\u003e \u003c/summary\u003e \n \n```{r}\noutput%\u003e%\n  dplyr::filter(type=='pull_request')%\u003e%\n  knitr::kable()\n\n```\n\n\u003c/details\u003e\n \n\u003cdetails\u003e\n\u003csummary\u003e \u003cspan title='Click to Expand'\u003e Issues Table \u003c/span\u003e \u003c/summary\u003e\n \n```{r}\noutput%\u003e%\n  dplyr::filter(type=='issue')%\u003e%\n  knitr::kable()\n\n```\n\n\u003c/details\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyonicd%2Ftidyghql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyonicd%2Ftidyghql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyonicd%2Ftidyghql/lists"}