Skip to content

Commit

Permalink
feat: add store json
Browse files Browse the repository at this point in the history
  • Loading branch information
gsxhnd committed Aug 8, 2024
1 parent f0605ad commit c4e8904
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
22 changes: 8 additions & 14 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@ jobs:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- run: echo ${{ steps.date.outputs.date }}

- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.22
id: go

- name: Get dependencies
run: go get -v -t -d ./...

- name: Download Database
- name: Download default database
uses: robinraju/release-downloader@v1
with:
tag: "db"
fileName: "tenhou_data.zip"
out-file-path: "./data"
extract: true

- name: unzip data
- name: unzip default database
run: unzip ./data/tenhou_data.zip
- run: mkdir ./data/tenhou_html && ls -al ./data

Expand All @@ -45,25 +43,21 @@ jobs:
- name: store to db
run: go run ./cmd recent_html_to_db

- name: zip
- name: zip default database
run: zip ./data/tenhou_data.zip ./data/tenhou_data.db

- name: rename db
- name: rename db to archive db
run: mv ./data/tenhou_data.db ./data/tenhou_data.${{ steps.date.outputs.date }}.db

- name: zip
- name: zip archive db
run: zip ./data/tenhou_data.${{ steps.date.outputs.date }}.zip ./data/tenhou_data.${{ steps.date.outputs.date }}.db

- run: ls -al ./data

- name: Upload
- name: Upload archive database
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./data/tenhou_data.${{ steps.date.outputs.date }}.zip
tag: db

- name: Upload
- name: Upload default database
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
23 changes: 23 additions & 0 deletions cmd/store_json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"github.com/gsxhnd/tenhou/db"
"github.com/gsxhnd/tenhou/utils"
"github.com/urfave/cli/v2"
"go.etcd.io/bbolt"
)

var storeJsonCmd = &cli.Command{
Name: "store_json",
Usage: "",
Action: func(ctx *cli.Context) error {
cfg, _ := utils.NewConfig()
logger := utils.NewLogger(cfg)
db, _ := db.NewDatabase(cfg, logger)
db.TenhouJsonDB.Batch(func(tx *bbolt.Tx) error {
// tx.Bucket([]byte{}).
return nil
})
return nil
},
}

0 comments on commit c4e8904

Please sign in to comment.