Skip to content

Commit

Permalink
switch translation to use ref
Browse files Browse the repository at this point in the history
  • Loading branch information
nandanrao committed Sep 11, 2022
1 parent 452341f commit 1376a13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scribble/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/jackc/pgx/v4 v4.8.1
github.com/stretchr/testify v1.6.1
github.com/vlab-research/spine v0.0.4
github.com/vlab-research/trans v0.0.9
github.com/vlab-research/trans v0.0.10
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
)
2 changes: 2 additions & 0 deletions scribble/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ github.com/vlab-research/trans v0.0.6 h1:ZZCWXru4xYwe8PZnLgp0KWB8nOGFZVJ8Yy4qTBQ
github.com/vlab-research/trans v0.0.6/go.mod h1:760R69NitmG7XcxEOF0OuuQjxvZiLGqG5sL493lmfjw=
github.com/vlab-research/trans v0.0.9 h1:yIHdcl+PLp5siRBS4RhQ+P2LGJeUnQcDSv0OcApnjoE=
github.com/vlab-research/trans v0.0.9/go.mod h1:760R69NitmG7XcxEOF0OuuQjxvZiLGqG5sL493lmfjw=
github.com/vlab-research/trans v0.0.10 h1:FdFz+mwrxuceJo/cjCbZ4vqAuJwgxrAjKpFvFfCxaMY=
github.com/vlab-research/trans v0.0.10/go.mod h1:760R69NitmG7XcxEOF0OuuQjxvZiLGqG5sL493lmfjw=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
Expand Down
12 changes: 7 additions & 5 deletions scribble/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"log"

"github.com/confluentinc/confluent-kafka-go/kafka"
"github.com/dgraph-io/ristretto"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (s *ResponseScribbler) SendBatch(data []Writeable) error {
return err
}

func getTranslationForms(pool *pgxpool.Pool, surveyid string) (*trans.FormJson, *trans.FormJson, error) {
func getTranslationForms(pool *pgxpool.Pool, surveyid string) (*trans.Form, *trans.Form, error) {
query := `
WITH t AS
(SELECT
Expand All @@ -103,8 +104,8 @@ func getTranslationForms(pool *pgxpool.Pool, surveyid string) (*trans.FormJson,
FROM t INNER JOIN surveys ON surveys.id = t.dest
`

src := new(trans.FormJson)
dest := new(trans.FormJson)
src := new(trans.Form)
dest := new(trans.Form)
err := pool.QueryRow(context.Background(), query, surveyid).Scan(src, dest)

return src, dest, err
Expand All @@ -126,7 +127,7 @@ func (r ResponseScribbler) cachedTranslator(response *Response) (*trans.FormTran
return nil, nil
}

translator, err := trans.MakeTranslatorByShape(src, dest)
translator, err := trans.MakeTranslatorByRef(src, dest)
if err != nil {
// This shouldn't happen, it's an error!
return nil, err
Expand All @@ -139,7 +140,8 @@ func (r ResponseScribbler) cachedTranslator(response *Response) (*trans.FormTran
func (r ResponseScribbler) Translate(response *Response) (*string, error) {
translator, err := r.cachedTranslator(response)
if err != nil {
return nil, err
log.Println(err)
return nil, nil
}

if translator == nil {
Expand Down

0 comments on commit 1376a13

Please sign in to comment.