Files
android_development/tools/repo_diff/service/repodiff/repositories/commit.go
Scott Lobdell 96629bd335 Base commit for service layer for repo diff tooling
Test: Changes are currently independent of the rest of this project. Tests can
currently manually be run with "make test". CL is large, but poses no
risk

Change-Id: Ia77e073df077257cab96b7ca4e1d99a900d029b2
2018-03-06 13:38:05 -08:00

42 lines
780 B
Go

package repositories
import (
"database/sql"
"github.com/pkg/errors"
e "repodiff/entities"
"repodiff/mappers"
repoSQL "repodiff/persistence/sql"
)
type commit struct {
db *sql.DB
}
func (c commit) InsertCommitRows(commitRows []e.CommitRow) error {
return errors.Wrap(
repoSQL.SingleTransactionInsert(
c.db,
`INSERT INTO project_commit (
timestamp,
uuid,
row_index,
commit_,
downstream_project,
author,
subject
) VALUES (?, ?, ?, ?, ?, ?, ?)`,
mappers.CommitRowsToPersistCols(commitRows),
),
"Error inserting rows into project_commit",
)
}
func NewCommitRepository() (commit, error) {
db, err := repoSQL.GetDBConnectionPool()
return commit{
db: db,
}, errors.Wrap(err, "Could not establish a database connection")
}