Skip to content

Commit

Permalink
Add SQLite section to README
Browse files Browse the repository at this point in the history
  • Loading branch information
bbkane committed Jan 26, 2022
1 parent 9f3183e commit ad42ed4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 15 deletions.
73 changes: 58 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

Save information about starred GitHub repos to a CSV or JSON file, and upload CSVs to Google Sheets!

**Click here to see [My GitHub Stars Google Sheet](https://docs.google.com/spreadsheets/d/15AXUtql31P62zxvEnqxNnb8ZcCWnBUYpROAsrtAhOV0/edit?usp=sharing)**

![star-count-over-time.png](./star-count-over-time.png)

Thanks to https://github.com/yks0000/starred-repo-toc for the inspiration!

GraphQL and Google Sheets auth notes at [./dev_notes.md](./dev_notes.md)
Expand All @@ -17,7 +13,7 @@ GraphQL and Google Sheets auth notes at [./dev_notes.md](./dev_notes.md)
- Go: `go install github.com/bbkane/starghaze@latest`
- Build with [goreleaser](https://goreleaser.com/) after cloning: `goreleaser --snapshot --skip-publish --rm-dist`

## Save Stars to Google Sheets
## Download GitHub Stars

### Download Star Info

Expand All @@ -27,11 +23,12 @@ GITHUB_TOKEN=my_github_token starghaze download \
--output stars.jsonl
```

## Google Sheets

### Format Downloaded Stars as CSV

````bash
starghaze format \
--input stars.jsonl \
--format csv \
--include-readmes false \
--output stars.csv
Expand All @@ -47,24 +44,22 @@ GOOGLE_APPLICATION_CREDENTIALS=/path/to/keys.json starghaze gsheets upload \
--timeout 30s
```

## Save Stars to [Zinc](https://github.com/prabhatsharma/zinc)
### Analyze Away!

### Download Star Info
**Click here to see [My GitHub Stars Google Sheet](https://docs.google.com/spreadsheets/d/15AXUtql31P62zxvEnqxNnb8ZcCWnBUYpROAsrtAhOV0/edit?usp=sharing)**

```bash
GITHUB_TOKEN=my_github_token starghaze download \
--include-readmes true \
--output stars.jsonl
```
![star-count-over-time.png](./star-count-over-time.png)

## Save Stars to [Zinc](https://github.com/prabhatsharma/zinc)

### Format Downloaded Stars as Zinc

```bash
starghaze format \
--include-readmes true \
--input stars.jsonl \
--format zinc \
--output stars.zinc
--output stars.zinc \
--zinc-index-name starghaze
```

### Upload to Zinc
Expand All @@ -74,3 +69,51 @@ Using default settings - See [Zinc repo](https://github.com/prabhatsharma/zinc)
```bash
curl http://localhost:4080/api/_bulk -i -u admin:Complexpass#123 --data-binary "@stars.zinc"
```

### Search!

![starghaze-zinc.png](starghaze-zinc.png)

## SQLite

### Format Downloaded Stars to SQLite (with [full text](https://www.sqlite.org/fts5.html) search)

```bash
starghaze format \
--format sqlite \
--include-readmes true \
--sqlite-dsn starghaze.db
```

### Query!

For example, find the top 10 languages (as measured by number of repos) in the starred collection.

```bash
$ sqlite3 starghaze.db '
SELECT
l.Name ,
COUNT(lr.Language_id) as Repo_Count
FROM
Language_Repo lr JOIN Language l ON lr.Language_id = l.id
GROUP BY Language_id
ORDER BY Repo_Count DESC
LIMIT 10
'
-- Loading resources from /Users/bbkane/.sqliterc
┌────────────┬────────────┐
│ Name │ Repo_Count │
├────────────┼────────────┤
│ Shell │ 939 │
│ JavaScript │ 617 │
│ HTML │ 598 │
│ Python │ 540 │
│ Makefile │ 519 │
│ CSS │ 432 │
│ Dockerfile │ 403 │
│ Go │ 367 │
│ C │ 305 │
│ C++ │ 230 │
└────────────┴────────────┘
```

Binary file added starghaze-zinc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ad42ed4

Please sign in to comment.