Interface-ify shared repository

This commit is contained in:
Edvard 2018-12-11 11:35:13 +01:00
parent 83593cb5f2
commit d93817f346
32 changed files with 90 additions and 78 deletions

View File

@ -47,8 +47,9 @@ func backfillMakerLogs() {
log.Fatal("Failed to initialize database.")
}
repository := shared2.Repository{}
fetcher := shared2.NewFetcher(blockChain)
watcher := shared.NewWatcher(db, fetcher)
watcher := shared.NewWatcher(db, fetcher, repository)
watcher.AddTransformers(transformers.TransformerInitializers())
watcher.Execute()

View File

@ -3,11 +3,18 @@ package shared
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/transformers"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
)
type WatcherRepository interface {
GetCheckedColumnNames(db *postgres.DB) ([]string, error)
CreateNotCheckedSQL(boolColumns []string) string
MissingHeaders(startingBlockNumber int64, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error)
}
type Watcher struct {
Transformers []shared.Transformer
DB *postgres.DB
@ -15,9 +22,10 @@ type Watcher struct {
Chunker shared.LogChunker
Addresses []common.Address
Topics []common.Hash
Repository WatcherRepository
}
func NewWatcher(db *postgres.DB, fetcher shared.LogFetcher) Watcher {
func NewWatcher(db *postgres.DB, fetcher shared.LogFetcher, repository WatcherRepository) Watcher {
transformerConfigs := transformers.TransformerConfigs()
var contractAddresses []common.Address
var topic0s []common.Hash
@ -32,11 +40,12 @@ func NewWatcher(db *postgres.DB, fetcher shared.LogFetcher) Watcher {
chunker := shared.NewLogChunker(transformerConfigs)
return Watcher{
DB: db,
Fetcher: fetcher,
Chunker: chunker,
Addresses: contractAddresses,
Topics: topic0s,
DB: db,
Fetcher: fetcher,
Chunker: chunker,
Addresses: contractAddresses,
Topics: topic0s,
Repository: repository,
}
}
@ -48,14 +57,14 @@ func (watcher *Watcher) AddTransformers(us []shared.TransformerInitializer) {
}
func (watcher *Watcher) Execute() error {
checkedColumnNames, err := shared.GetCheckedColumnNames(watcher.DB)
checkedColumnNames, err := watcher.Repository.GetCheckedColumnNames(watcher.DB)
if err != nil {
return err
}
notCheckedSQL := shared.CreateNotCheckedSQL(checkedColumnNames)
notCheckedSQL := watcher.Repository.CreateNotCheckedSQL(checkedColumnNames)
// TODO Handle start and end numbers in transformers?
missingHeaders, err := shared.MissingHeaders(0, -1, watcher.DB, notCheckedSQL)
// TODO Handle start and end numbers in transformers
missingHeaders, err := watcher.Repository.MissingHeaders(0, -1, watcher.DB, notCheckedSQL)
if err != nil {
log.Error("Fetching of missing headers failed in watcher!")
return err
@ -66,7 +75,7 @@ func (watcher *Watcher) Execute() error {
logs, err := watcher.Fetcher.FetchLogs(watcher.Addresses, watcher.Topics, header)
if err != nil {
// TODO Handle fetch error in watcher
log.Error("Error while fetching logs in watcher")
log.Error("Error while fetching logs for header %v in watcher", header.Id)
return err
}
@ -76,7 +85,7 @@ func (watcher *Watcher) Execute() error {
logChunk := chunkedLogs[transformer.Name()]
err = transformer.Execute(logChunk, header)
if err != nil {
log.Error("%v transformer failed to execute: %v", transformer.Name(), err)
log.Error("%v transformer failed to execute in watcher: %v", transformer.Name(), err)
return err
}
}

View File

@ -52,7 +52,7 @@ func (repository BiteRepository) Create(headerID int64, models []interface{}) er
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.BiteChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.BiteChecked)
if err != nil {
tx.Rollback()
return err
@ -62,5 +62,5 @@ func (repository BiteRepository) Create(headerID int64, models []interface{}) er
}
func (repository BiteRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.BiteChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.BiteChecked)
}

View File

@ -49,7 +49,7 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []inte
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileChopLumpChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileChopLumpChecked)
if err != nil {
tx.Rollback()
return err
@ -58,7 +58,7 @@ func (repository CatFileChopLumpRepository) Create(headerID int64, models []inte
}
func (repository CatFileChopLumpRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFileChopLumpChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFileChopLumpChecked)
}
func (repository *CatFileChopLumpRepository) SetDB(db *postgres.DB) {

View File

@ -48,7 +48,7 @@ func (repository CatFileFlipRepository) Create(headerID int64, models []interfac
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileFlipChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileFlipChecked)
if err != nil {
tx.Rollback()
return err
@ -57,7 +57,7 @@ func (repository CatFileFlipRepository) Create(headerID int64, models []interfac
}
func (repository CatFileFlipRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFileFlipChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFileFlipChecked)
}
func (repository *CatFileFlipRepository) SetDB(db *postgres.DB) {

View File

@ -48,7 +48,7 @@ func (repository CatFilePitVowRepository) Create(headerID int64, models []interf
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFilePitVowChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFilePitVowChecked)
if err != nil {
tx.Rollback()
return err
@ -57,7 +57,7 @@ func (repository CatFilePitVowRepository) Create(headerID int64, models []interf
}
func (repository CatFilePitVowRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFilePitVowChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.CatFilePitVowChecked)
}
func (repository *CatFilePitVowRepository) SetDB(db *postgres.DB) {

View File

@ -49,7 +49,7 @@ func (repository DealRepository) Create(headerID int64, models []interface{}) er
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DealChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DealChecked)
if err != nil {
tx.Rollback()
return err
@ -58,7 +58,7 @@ func (repository DealRepository) Create(headerID int64, models []interface{}) er
}
func (repository DealRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.DealChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DealChecked)
}
func (repository *DealRepository) SetDB(db *postgres.DB) {

View File

@ -54,7 +54,7 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DentChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DentChecked)
if err != nil {
tx.Rollback()
return err
@ -63,7 +63,7 @@ func (repository DentRepository) Create(headerID int64, models []interface{}) er
}
func (repository DentRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.DentChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.DentChecked)
}
func (repository *DentRepository) SetDB(db *postgres.DB) {

View File

@ -48,7 +48,7 @@ func (repository DripDripRepository) Create(headerID int64, models []interface{}
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripDripChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripDripChecked)
if err != nil {
tx.Rollback()
return err
@ -57,7 +57,7 @@ func (repository DripDripRepository) Create(headerID int64, models []interface{}
}
func (repository DripDripRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.DripDripChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripDripChecked)
}
func (repository *DripDripRepository) SetDB(db *postgres.DB) {

View File

@ -50,7 +50,7 @@ func (repository DripFileIlkRepository) Create(headerID int64, models []interfac
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileIlkChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileIlkChecked)
if err != nil {
tx.Rollback()
return err
@ -60,7 +60,7 @@ func (repository DripFileIlkRepository) Create(headerID int64, models []interfac
}
func (repository DripFileIlkRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileIlkChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileIlkChecked)
}
func (repository *DripFileIlkRepository) SetDB(db *postgres.DB) {

View File

@ -50,7 +50,7 @@ func (repository DripFileRepoRepository) Create(headerID int64, models []interfa
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileRepoChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileRepoChecked)
if err != nil {
tx.Rollback()
return err
@ -60,7 +60,7 @@ func (repository DripFileRepoRepository) Create(headerID int64, models []interfa
}
func (repository DripFileRepoRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileRepoChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileRepoChecked)
}
func (repository *DripFileRepoRepository) SetDB(db *postgres.DB) {

View File

@ -49,7 +49,7 @@ func (repository DripFileVowRepository) Create(headerID int64, models []interfac
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileVowChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileVowChecked)
if err != nil {
tx.Rollback()
return err
@ -59,7 +59,7 @@ func (repository DripFileVowRepository) Create(headerID int64, models []interfac
}
func (repository DripFileVowRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileVowChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.DripFileVowChecked)
}
func (repository *DripFileVowRepository) SetDB(db *postgres.DB) {

View File

@ -47,7 +47,7 @@ func (repository *FlapKickRepository) Create(headerID int64, models []interface{
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlapKickChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlapKickChecked)
if err != nil {
tx.Rollback()
return err
@ -56,7 +56,7 @@ func (repository *FlapKickRepository) Create(headerID int64, models []interface{
}
func (repository *FlapKickRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.FlapKickChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.FlapKickChecked)
}
func (repository *FlapKickRepository) SetDB(db *postgres.DB) {

View File

@ -47,7 +47,7 @@ func (repository FlipKickRepository) Create(headerID int64, models []interface{}
return err
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlipKickChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlipKickChecked)
if err != nil {
tx.Rollback()
return err
@ -56,7 +56,7 @@ func (repository FlipKickRepository) Create(headerID int64, models []interface{}
}
func (repository FlipKickRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.FlipKickChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.FlipKickChecked)
}
func (repository *FlipKickRepository) SetDB(db *postgres.DB) {

View File

@ -48,7 +48,7 @@ func (repository FlopKickRepository) Create(headerID int64, models []interface{}
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlopKickChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlopKickChecked)
if err != nil {
tx.Rollback()
return err
@ -58,7 +58,7 @@ func (repository FlopKickRepository) Create(headerID int64, models []interface{}
}
func (repository FlopKickRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.FlopKickChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.FlopKickChecked)
}
func (repository *FlopKickRepository) SetDB(db *postgres.DB) {

View File

@ -46,7 +46,7 @@ func (repository FrobRepository) Create(headerID int64, models []interface{}) er
return err
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FrobChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.FrobChecked)
if err != nil {
tx.Rollback()
return err
@ -55,7 +55,7 @@ func (repository FrobRepository) Create(headerID int64, models []interface{}) er
}
func (repository FrobRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.FrobChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.FrobChecked)
}
func (repository *FrobRepository) SetDB(db *postgres.DB) {

View File

@ -50,7 +50,7 @@ func (repository PitFileDebtCeilingRepository) Create(headerID int64, models []i
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileDebtCeilingChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileDebtCeilingChecked)
if err != nil {
tx.Rollback()
return err
@ -60,7 +60,7 @@ func (repository PitFileDebtCeilingRepository) Create(headerID int64, models []i
}
func (repository PitFileDebtCeilingRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.PitFileDebtCeilingChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PitFileDebtCeilingChecked)
}
func (repository *PitFileDebtCeilingRepository) SetDB(db *postgres.DB) {

View File

@ -49,7 +49,7 @@ func (repository PitFileIlkRepository) Create(headerID int64, models []interface
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileIlkChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileIlkChecked)
if err != nil {
tx.Rollback()
return err
@ -58,7 +58,7 @@ func (repository PitFileIlkRepository) Create(headerID int64, models []interface
}
func (repository PitFileIlkRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.PitFileIlkChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PitFileIlkChecked)
}
func (repository *PitFileIlkRepository) SetDB(db *postgres.DB) {

View File

@ -45,7 +45,7 @@ func (repository PriceFeedRepository) Create(headerID int64, models []interface{
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PriceFeedsChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.PriceFeedsChecked)
if err != nil {
tx.Rollback()
return err
@ -54,7 +54,7 @@ func (repository PriceFeedRepository) Create(headerID int64, models []interface{
}
func (repository PriceFeedRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.PriceFeedsChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.PriceFeedsChecked)
}
func (repository *PriceFeedRepository) SetDB(db *postgres.DB) {

View File

@ -9,7 +9,9 @@ import (
"strings"
)
func MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHeadersColumn string) error {
type Repository struct{}
func (_ Repository) MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHeadersColumn string) error {
_, err := db.Exec(`INSERT INTO public.checked_headers (header_id, `+checkedHeadersColumn+`)
VALUES ($1, $2)
ON CONFLICT (header_id) DO
@ -17,7 +19,7 @@ func MarkHeaderChecked(headerID int64, db *postgres.DB, checkedHeadersColumn str
return err
}
func MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersColumn string) error {
func (_ Repository) MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersColumn string) error {
_, err := tx.Exec(`INSERT INTO public.checked_headers (header_id, `+checkedHeadersColumn+`)
VALUES ($1, $2)
ON CONFLICT (header_id) DO
@ -26,7 +28,7 @@ func MarkHeaderCheckedInTransaction(headerID int64, tx *sql.Tx, checkedHeadersCo
}
// Treats a header as missing if it's not in the headers table, or not checked for some log type
func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) {
func (_ Repository) MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, notCheckedSQL string) ([]core.Header, error) {
var result []core.Header
var query string
var err error
@ -51,7 +53,7 @@ func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.D
return result, err
}
func GetCheckedColumnNames(db *postgres.DB) ([]string, error) {
func (_ Repository) GetCheckedColumnNames(db *postgres.DB) ([]string, error) {
// Query returns `[]driver.Value`, nullable polymorphic interface
var queryResult []driver.Value
columnNamesQuery :=
@ -83,7 +85,7 @@ func GetCheckedColumnNames(db *postgres.DB) ([]string, error) {
// Defaults to FALSE when no columns are provided.
// Ex: ["columnA", "columnB"] => "NOT (columnA AND columnB)"
// [] => "FALSE"
func CreateNotCheckedSQL(boolColumns []string) string {
func (_ Repository) CreateNotCheckedSQL(boolColumns []string) string {
var result strings.Builder
if len(boolColumns) == 0 {

View File

@ -27,7 +27,7 @@ var _ = Describe("Repository utilities", func() {
db := test_config.NewTestDB(test_config.NewTestNode())
test_config.CleanTestDB(db)
expectedColumnNames := getExpectedColumnNames()
actualColumnNames, err := shared.GetCheckedColumnNames(db)
actualColumnNames, err := shared.Repository{}.GetCheckedColumnNames(db)
Expect(err).NotTo(HaveOccurred())
Expect(actualColumnNames).To(Equal(expectedColumnNames))
})
@ -37,20 +37,20 @@ var _ = Describe("Repository utilities", func() {
It("generates a correct SQL string for one column", func() {
columns := []string{"columnA"}
expected := "NOT (columnA)"
actual := shared.CreateNotCheckedSQL(columns)
actual := shared.Repository{}.CreateNotCheckedSQL(columns)
Expect(actual).To(Equal(expected))
})
It("generates a correct SQL string for several columns", func() {
columns := []string{"columnA", "columnB"}
expected := "NOT (columnA AND columnB)"
actual := shared.CreateNotCheckedSQL(columns)
actual := shared.Repository{}.CreateNotCheckedSQL(columns)
Expect(actual).To(Equal(expected))
})
It("defaults to FALSE when there are no columns", func() {
expected := "FALSE"
actual := shared.CreateNotCheckedSQL([]string{})
actual := shared.Repository{}.CreateNotCheckedSQL([]string{})
Expect(actual).To(Equal(expected))
})
})

View File

@ -55,7 +55,7 @@ func (repository TendRepository) Create(headerID int64, models []interface{}) er
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.TendChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.TendChecked)
if err != nil {
tx.Rollback()
return err
@ -64,7 +64,7 @@ func (repository TendRepository) Create(headerID int64, models []interface{}) er
}
func (repository TendRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.TendChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.TendChecked)
}
func (repository *TendRepository) SetDB(db *postgres.DB) {

View File

@ -47,7 +47,7 @@ func (repository VatFluxRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFluxChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFluxChecked)
if err != nil {
tx.Rollback()
return err
@ -57,7 +57,7 @@ func (repository VatFluxRepository) Create(headerID int64, models []interface{})
}
func (repository VatFluxRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.VatFluxChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.VatFluxChecked)
}
func (repository *VatFluxRepository) SetDB(db *postgres.DB) {

View File

@ -49,7 +49,7 @@ func (repository VatFoldRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFoldChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatFoldChecked)
if err != nil {
tx.Rollback()
return err
@ -59,7 +59,7 @@ func (repository VatFoldRepository) Create(headerID int64, models []interface{})
}
func (repository VatFoldRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatFoldChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatFoldChecked)
}
func (repository *VatFoldRepository) SetDB(db *postgres.DB) {

View File

@ -34,7 +34,7 @@ func (repository VatGrabRepository) Create(headerID int64, models []interface{})
return err
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatGrabChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatGrabChecked)
if err != nil {
tx.Rollback()
return err
@ -43,7 +43,7 @@ func (repository VatGrabRepository) Create(headerID int64, models []interface{})
}
func (repository VatGrabRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatGrabChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatGrabChecked)
}
func (repository *VatGrabRepository) SetDB(db *postgres.DB) {

View File

@ -52,7 +52,7 @@ func (repository VatHealRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatHealChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatHealChecked)
if err != nil {
tx.Rollback()
return err
@ -61,5 +61,5 @@ func (repository VatHealRepository) Create(headerID int64, models []interface{})
}
func (repository VatHealRepository) MarkHeaderChecked(headerId int64) error {
return shared.MarkHeaderChecked(headerId, repository.db, constants.VatHealChecked)
return shared.Repository{}.MarkHeaderChecked(headerId, repository.db, constants.VatHealChecked)
}

View File

@ -49,7 +49,7 @@ func (repository VatInitRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatInitChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatInitChecked)
if err != nil {
tx.Rollback()
return err
@ -59,7 +59,7 @@ func (repository VatInitRepository) Create(headerID int64, models []interface{})
}
func (repository VatInitRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatInitChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatInitChecked)
}
func (repository *VatInitRepository) SetDB(db *postgres.DB) {

View File

@ -50,7 +50,7 @@ func (repository VatMoveRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatMoveChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatMoveChecked)
if err != nil {
tx.Rollback()
return err
@ -60,7 +60,7 @@ func (repository VatMoveRepository) Create(headerID int64, models []interface{})
}
func (repository VatMoveRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatMoveChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatMoveChecked)
}
func (repository *VatMoveRepository) SetDB(db *postgres.DB) {

View File

@ -34,7 +34,7 @@ func (repository VatSlipRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatSlipChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatSlipChecked)
if err != nil {
tx.Rollback()
return err
@ -44,7 +44,7 @@ func (repository VatSlipRepository) Create(headerID int64, models []interface{})
}
func (repository VatSlipRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatSlipChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatSlipChecked)
}
func (repository *VatSlipRepository) SetDB(db *postgres.DB) {

View File

@ -34,7 +34,7 @@ func (repository VatTollRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTollChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTollChecked)
if err != nil {
tx.Rollback()
return err
@ -43,7 +43,7 @@ func (repository VatTollRepository) Create(headerID int64, models []interface{})
}
func (repository VatTollRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatTollChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatTollChecked)
}
func (repository *VatTollRepository) SetDB(db *postgres.DB) {

View File

@ -34,7 +34,7 @@ func (repository VatTuneRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTuneChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatTuneChecked)
if err != nil {
tx.Rollback()
return err
@ -43,7 +43,7 @@ func (repository VatTuneRepository) Create(headerID int64, models []interface{})
}
func (repository VatTuneRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VatTuneChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VatTuneChecked)
}
func (repository *VatTuneRepository) SetDB(db *postgres.DB) {

View File

@ -50,7 +50,7 @@ func (repository VowFlogRepository) Create(headerID int64, models []interface{})
}
}
err = shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VowFlogChecked)
err = shared.Repository{}.MarkHeaderCheckedInTransaction(headerID, tx, constants.VowFlogChecked)
if err != nil {
tx.Rollback()
return err
@ -60,7 +60,7 @@ func (repository VowFlogRepository) Create(headerID int64, models []interface{})
}
func (repository VowFlogRepository) MarkHeaderChecked(headerID int64) error {
return shared.MarkHeaderChecked(headerID, repository.db, constants.VowFlogChecked)
return shared.Repository{}.MarkHeaderChecked(headerID, repository.db, constants.VowFlogChecked)
}
func (repository *VowFlogRepository) SetDB(db *postgres.DB) {