Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

VDB-696 Update transformer execute #101

Merged
merged 6 commits into from
Jun 17, 2019

Conversation

elizabethengelman
Copy link
Contributor

No description provided.

@elizabethengelman elizabethengelman force-pushed the update-transformer-execute branch from d1c4d50 to b169d70 Compare June 13, 2019 14:59
@@ -24,7 +24,6 @@ import (
type Repository interface {
Create(headerID int64, models []interface{}) error
MarkHeaderChecked(headerID int64) error
MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This transformer specific MissingHeaders method was never being used. Instead this generic MissingHeaders method is being called the watcher and then the headers are passed into Transformer.Execute.

@@ -37,7 +36,7 @@ func (transformer Transformer) NewTransformer(db *postgres.DB) transformer.Event
return transformer
}

func (transformer Transformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error {
func (transformer Transformer) Execute(logs []types.Log, header core.Header) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recheckHeaders argument is not being used in this Execute method.

@elizabethengelman elizabethengelman force-pushed the update-transformer-execute branch from b169d70 to 48afe39 Compare June 13, 2019 15:33
@@ -69,31 +69,6 @@ func MissingHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.D
return result, err
}

func RecheckHeaders(startingBlockNumber, endingBlockNumber int64, db *postgres.DB, checkedHeadersColumn string) ([]core.Header, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this method wasn't being called any longer.

Also, something else I hadn't realized previously was that in order to allow for rechecking headers, we need to pass in a CLI argument --recheck-headers when running composeAndExecute. 🌠


var result bytes.Buffer

func CreateHeaderCheckedPredicateSQL(boolColumns []string, recheckHeaders constants.TransformerExecution) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored this method into two smaller ones & changed the name as I was trying to understand how it was working. If folks don't find this refactoring helpful, I'm happy to undo it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense this way 💯

@elizabethengelman elizabethengelman changed the title [WIP] Update transformer execute VDB-696 Update transformer execute Jun 13, 2019
@elizabethengelman elizabethengelman requested review from rmulhol, i-norden, m0ar, yaoandrew and Gslaughl and removed request for rmulhol June 13, 2019 20:31
Copy link
Contributor

@rmulhol rmulhol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing dead code, my favorite 🎉 👍 🥇 :shipit:

@@ -153,10 +149,11 @@ var _ = Describe("Repository", func() {
})

AfterEach(func() {
test_config.CleanCheckedHeadersTable(db, getExpectedColumnNames())
//test_config.CleanCheckedHeadersTable(db, getExpectedColumnNames())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to remove this AfterEach entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh nice catch! i think I commented this out so I could get some data in my test db - I think it should still hang around.

actual := shared.CreateNotCheckedSQL(columns, constants.HeaderMissing)
Expect(actual).To(Equal(expected))
})
Describe("CreateCustomColumnNamesSQL", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be "CreateHeaderCheckedPredicateSQL"?

expected := fmt.Sprintf("NOT (columnA>=%s AND columnB>=%s)", constants.RecheckHeaderCap, constants.RecheckHeaderCap)
actual := shared.CreateNotCheckedSQL(columns, constants.HeaderRecheck)
Expect(actual).To(Equal(expected))
Describe("RecheckHeadersCustomColumnNames", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rephrase to clarify how it's different from the above Describe

Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and I echo Rob's sentiment about removing dead code :) :)


var result bytes.Buffer

func CreateHeaderCheckedPredicateSQL(boolColumns []string, recheckHeaders constants.TransformerExecution) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes more sense this way 💯

@elizabethengelman elizabethengelman merged commit d761f88 into staging Jun 17, 2019
@elizabethengelman elizabethengelman deleted the update-transformer-execute branch June 17, 2019 20:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants