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

MANY breaking changes for the updated sdk version (for quals fix) and for better usability. Closes #15 #16

Merged
merged 3 commits into from
Mar 18, 2021
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
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The Github plugin uses a personal access token to authenticate to the Github API
- `repo` (all)
- `read:org`
- `read:user`
- `gist`
- `user:email`


Expand Down
14 changes: 3 additions & 11 deletions docs/tables/github_gist.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
# Table: github_gist

Github Gist is a simple way to share snippets and pastes with others. The `github_gist` table will list **public** gists that **you own**. You can query **ANY** gist that you have access to by specifying its `id` explicitly in the where clause with `where id =` .
Github Gist is a simple way to share snippets and pastes with others. You can query **ANY** gist that you have access to by specifying its `id` explicitly in the where clause with `where id =`. You must specify the `id` in a where clause or join key to use this table.

## Examples

### List your public gists

```sql
select
*
from
github_gist;
```
To list the gists that **you own**, use the `github_my_gist` table.

## Examples

### Get details about ANY public gist (by id)

Expand Down
115 changes: 115 additions & 0 deletions docs/tables/github_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Table: github_issue

Github Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub.

The `github_issue` table can be used to query issues belonging to a repository, and **you must specify which repository** with `where repository_full_name='owner/repository'`. To list all the issues **assigned to you across all repositories** use the `github_my_issue` table instead.

Note that pull requests are technically also issues in Github, however we do not include them in the `github_issue` table; You should use the `github_pull_request` table to query PRs.


## Examples

### List the issues in a repository
```sql
select
repository_full_name,
issue_number,
title,
state,
author_login,
assignee_logins
from
github_issue
where
repository_full_name = 'turbot/steampipe';
```


### List the unassigned open issues in a repository

```sql
select
repository_full_name,
issue_number,
title,
state,
author_login,
assignee_logins
from
github_issue
where
repository_full_name = 'turbot/steampipe'
and jsonb_array_length(assignee_logins) = 0
and state = 'open';

```

### List the open issues in a repository with a given label

```sql
select
repository_full_name,
issue_number,
title,
state,
tags
from
github_issue
where
repository_full_name = 'turbot/steampipe'
and state = 'open'
and tags ? 'bug';
```


### List the open issues in a repository assigned to a specific user

```sql
select
repository_full_name,
issue_number,
title,
state,
assigned_to
from
github_issue,
jsonb_array_elements_text(assignee_logins) as assigned_to
where
repository_full_name = 'turbot/steampipe'
and assigned_to = 'binaek89'
and state = 'open';
```


### Report of the number issues in a repository by author

```sql
select
author_login,
count(*) as num_issues
from
github_issue
where
repository_full_name = 'turbot/steampipe'
group by
author_login
order by
num_issues desc;
```


### Join with github_my_repository to find open issues in multiple repos that you own or contribute to
```sql
select
i.repository_full_name,
i.issue_number,
i.title
from
github_my_repository as r,
github_issue as i
where
r.full_name like 'turbot/steampip%'
and i.state = 'open'
and i.repository_full_name = r.full_name;
```

6 changes: 3 additions & 3 deletions docs/tables/github_license.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ select
name,
jsonb_pretty(permissions)
from
github_license
github_license;
```


### Count repositories by license
### Count your repositories by license

```sql
select
l.name,
count(r.license_key) as num_repos
from
github_license as l
left join github_repository as r on l.key = r.license_key
left join github_my_repository as r on l.key = r.license_key
group by
l.name
order by
Expand Down
28 changes: 28 additions & 0 deletions docs/tables/github_my_gist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Table: github_my_gist

Github Gist is a simple way to share snippets and pastes with others. The `github_my_gist` table will list only gists that **you own**.

To query **ANY** gist that you have access to (including any public gists), use the `github_gist` table.

## Examples

### List your gists

```sql
select
*
from
github_my_gist;
```


### List your public gists

```sql
select
*
from
github_my_gist
where
public;
```
62 changes: 62 additions & 0 deletions docs/tables/github_my_issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Table: github_my_issue

Github Issues are used to track ideas, enhancements, tasks, or bugs for work on GitHub. The `github_my_issue` table lists issues that are assigned to you, across all repositories.

To view **all the issues belonging to a repository**, use the `github_issue` table.


## Examples

### List all of the open issues assigned to you
```sql
select
repository_full_name,
issue_number,
title,
state,
author_login,
assignee_logins
from
github_my_issue
where
state = 'open';
```


### List your open issues with a given label

```sql
select
repository_full_name,
issue_number,
title,
state,
tags
from
github_my_issue
where
state = 'open'
and tags ? 'bug';
```


### List your 10 oldest open issues

```sql
select
repository_full_name,
issue_number,
created_at,
age (created_at),
title,
state
from
github_my_issue
where
state = 'open'
order by
created_at
limit 10;
```


77 changes: 77 additions & 0 deletions docs/tables/github_my_organization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Table: github_my_organization

Organizations are shared accounts where businesses and open-source projects can collaborate across many projects at once. Owners and administrators can manage member access to the organization's data and projects with sophisticated security and administrative features.

The `github_my_organization` table will list the organization **that you are a member of**. To view details of **ANY** organization, use the `github_organization` table.

## Examples

### Basic info for the Github Organizations to which you belong

```sql
select
login as organization,
name,
twitter_username,
total_private_repos,
public_repos,
plan_name,
plan_seats,
plan_filled_seats
from
github_my_organization;
```


### Show members of an organization

```sql
select
login as organization,
name,
m ->> 'login' as member_login,
m ->> 'type' as member_type
from
github_my_organization,
jsonb_array_elements(members) as m
where
login = 'turbot';
```


### Show Organization security settings

```sql
select
login as organization,
jsonb_array_length(members) as num_members,
members_allowed_repository_creation_type,
members_can_create_internal_repos,
members_can_create_pages,
members_can_create_private_repos,
members_can_create_public_repos,
members_can_create_repos,
members_can_create_repositories,
default_repo_permission,
two_factor_requirement_enabled
from
github_my_organization;
```


### Show collaborators in your organization's repositories that are not members of the organization

```sql
select
r.name,
collaborator_login
from
github_my_repository as r,
jsonb_array_elements_text(r.collaborator_logins) as collaborator_login,
github_my_organization as o
where
r.owner_login = o.login
and collaborator_login not in (
select m from github_my_organization, jsonb_array_elements_text(member_logins) as m
) ;
```
Loading