adjust mat selection
This commit is contained in:
parent
17030c72ce
commit
bf693aab2a
15 changed files with 548 additions and 186 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
|
|
@ -16,7 +17,8 @@ CREATE TABLE IF NOT EXISTS commit_log (
|
|||
msg VARCHAR(255),
|
||||
created_at DATETIME,
|
||||
editor VARCHAR(255),
|
||||
change_file VARCHAR(255)
|
||||
change_file VARCHAR(255),
|
||||
relation VARCHAR(255)
|
||||
);
|
||||
`
|
||||
|
||||
|
|
@ -26,6 +28,7 @@ type CommitLog struct {
|
|||
Created_at string `db:"created_at"`
|
||||
Editor string `db:"editor"`
|
||||
Change_file string `db:"change_file"`
|
||||
Relation string `db:"relation"`
|
||||
}
|
||||
|
||||
func HashCommit(n int) (string, error) {
|
||||
|
|
@ -52,7 +55,7 @@ func Insert(c *CommitLog) error {
|
|||
// init table in db
|
||||
commit_db.MustExec(schema)
|
||||
|
||||
_, err = commit_db.NamedExec("INSERT INTO commit_log (id, msg, created_at, editor, change_file) VALUES (:id, :msg, :created_at, :editor, :change_file)", c)
|
||||
_, err = commit_db.NamedExec("INSERT INTO commit_log (id, msg, created_at, editor, change_file, relation) VALUES (:id, :msg, :created_at, :editor, :change_file, :relation)", c)
|
||||
if err != nil {
|
||||
|
||||
return err
|
||||
|
|
@ -74,8 +77,10 @@ func GetCommitLogOfFilename(countryId string, filename string) ([]CommitLog, err
|
|||
}
|
||||
|
||||
commitDB, err := sqlx.Connect("sqlite3", "./data/database.db")
|
||||
// fmt.Println("GetCommitLogOfFilename", err)
|
||||
if err != nil {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var commits []CommitLog
|
||||
|
|
@ -84,6 +89,12 @@ func GetCommitLogOfFilename(countryId string, filename string) ([]CommitLog, err
|
|||
|
||||
err = commitDB.Select(&commits, "SELECT * FROM commit_log WHERE change_file LIKE ?", "%"+filename+"%")
|
||||
|
||||
// fmt.Println("commits", err)
|
||||
if err != nil {
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var commitsByCountryID []CommitLog
|
||||
|
||||
for _, v := range commits {
|
||||
|
|
@ -101,6 +112,12 @@ func GetCommitLogOfFilename(countryId string, filename string) ([]CommitLog, err
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// fmt.Println("commitsByCountryID", len(commitsByCountryID) == 0)
|
||||
if len(commitsByCountryID) == 0 {
|
||||
|
||||
return nil, fmt.Errorf("no commit found for %s", filename)
|
||||
}
|
||||
|
||||
return commitsByCountryID, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue