Skip to content

Commit

Permalink
add replacer for newline in symbols&names.
Browse files Browse the repository at this point in the history
  • Loading branch information
jppade committed Aug 7, 2023
1 parent c778048 commit e657782
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/services/filtersBlockService/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/services/filtersBlockService
go 1.17

require (
github.com/diadata-org/diadata v1.4.297
github.com/diadata-org/diadata v1.4.321
github.com/segmentio/kafka-go v0.4.35
github.com/sirupsen/logrus v1.8.1
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/services/tradesBlockService/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/services/tradesBlockService
go 1.17

require (
github.com/diadata-org/diadata v1.4.319
github.com/diadata-org/diadata v1.4.321
github.com/segmentio/kafka-go v0.4.35
github.com/sirupsen/logrus v1.8.1
)
Expand Down
5 changes: 4 additions & 1 deletion pkg/model/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
"time"

"github.com/diadata-org/diadata/pkg/dia/helpers/db"
Expand Down Expand Up @@ -153,6 +154,8 @@ type DB struct {
influxPointsInBatch int
}

var EscapeReplacer = strings.NewReplacer("\n", `\n`)

const (
influxDbName = "dia"
influxDbTradesTable = "trades"
Expand Down Expand Up @@ -312,7 +315,7 @@ func (datastore *DB) CopyInfluxMeasurements(dbOrigin string, dbDestination strin

func (datastore *DB) SetVWAPFirefly(foreignName string, value float64, timestamp time.Time) error {
tags := map[string]string{
"foreignName": foreignName,
"foreignName": EscapeReplacer.Replace(foreignName),
}
fields := map[string]interface{}{
"value": value,
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ func (datastore *DB) SaveFilterInflux(filter string, asset dia.Asset, exchange s
// Create a point and add to batch
tags := map[string]string{
"filter": filter,
"symbol": asset.Symbol,
"address": asset.Address,
"symbol": EscapeReplacer.Replace(asset.Symbol),
"address": EscapeReplacer.Replace(asset.Address),
"blockchain": asset.Blockchain,
"exchange": exchange,
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/model/quotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func (datastore *DB) GetAssetPriceUSD(asset dia.Asset, timestamp time.Time) (pri
func (datastore *DB) AddAssetQuotationsToBatch(quotations []*AssetQuotation) error {
for _, quotation := range quotations {
tags := map[string]string{
"symbol": quotation.Asset.Symbol,
"name": quotation.Asset.Name,
"symbol": EscapeReplacer.Replace(quotation.Asset.Symbol),
"name": EscapeReplacer.Replace(quotation.Asset.Name),
"address": quotation.Asset.Address,
"blockchain": quotation.Asset.Blockchain,
}
Expand All @@ -99,8 +99,8 @@ func (datastore *DB) AddAssetQuotationsToBatch(quotations []*AssetQuotation) err
func (datastore *DB) SetAssetQuotation(quotation *AssetQuotation) error {
// Write to influx
tags := map[string]string{
"symbol": quotation.Asset.Symbol,
"name": quotation.Asset.Name,
"symbol": EscapeReplacer.Replace(quotation.Asset.Symbol),
"name": EscapeReplacer.Replace(quotation.Asset.Name),
"address": quotation.Asset.Address,
"blockchain": quotation.Asset.Blockchain,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/supplies.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func (datastore *DB) SaveSupplyInflux(supply *dia.Supply) error {
"source": supply.Source,
}
tags := map[string]string{
"symbol": supply.Asset.Symbol,
"name": supply.Asset.Name,
"symbol": EscapeReplacer.Replace(supply.Asset.Symbol),
"name": EscapeReplacer.Replace(supply.Asset.Name),
"address": supply.Asset.Address,
"blockchain": supply.Asset.Blockchain,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/synthAssets.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ func (datastore *DB) SaveSynthSupplyInfluxToTable(t *dia.SynthAssetSupply, table

// Create a point and add to batch
tags := map[string]string{
"synthassetsymbol": t.Asset.Symbol,
"underlyingassetsymbol": t.AssetUnderlying.Symbol,
"synthassetsymbol": EscapeReplacer.Replace(t.Asset.Symbol),
"underlyingassetsymbol": EscapeReplacer.Replace(t.AssetUnderlying.Symbol),
"synthtokenaddress": t.Asset.Address,
"underlyingtokenaddress": t.AssetUnderlying.Address,
"blockchain": t.Asset.Blockchain,
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/trades.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (datastore *DB) SaveTradeInfluxToTable(t *dia.Trade, table string) error {

// Create a point and add to batch
tags := map[string]string{
"symbol": t.Symbol,
"symbol": EscapeReplacer.Replace(t.Symbol),
"pair": t.Pair,
"exchange": t.Source,
"verified": strconv.FormatBool(t.VerifiedPair),
Expand Down

0 comments on commit e657782

Please sign in to comment.