Jj/payments cleanup (#1379)

* Removes date from payments csv and re-query of wallet addr

* removes dbx get wallet addr

* switch order in csv
This commit is contained in:
Jennifer Li Johnson 2019-02-28 12:13:59 -05:00 committed by GitHub
parent 4122c98cb7
commit 6ecda190cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2 additions and 93 deletions

View File

@ -43,9 +43,8 @@ func generateCSV(ctx context.Context, start time.Time, end time.Time, output io.
"bytes:BWRepair-GET",
"bytes:BWRepair-PUT",
"bytes:BWAudit",
"bytes:BWGet",
"bytes:BWPut",
"date",
"bytes:BWGet",
"walletAddress",
}
if err := w.Write(headers); err != nil {
@ -53,12 +52,6 @@ func generateCSV(ctx context.Context, start time.Time, end time.Time, output io.
}
for _, row := range rows {
nid := row.NodeID
wallet, err := db.OverlayCache().GetWalletAddress(ctx, nid)
if err != nil {
return err
}
row.Wallet = wallet
record := structToStringSlice(row)
if err := w.Write(record); err != nil {
return err
@ -83,9 +76,8 @@ func structToStringSlice(s *accounting.CSVRow) []string {
strconv.FormatInt(s.GetRepairTotal, 10),
strconv.FormatInt(s.PutRepairTotal, 10),
strconv.FormatInt(s.GetAuditTotal, 10),
strconv.FormatInt(s.GetTotal, 10),
strconv.FormatInt(s.PutTotal, 10),
s.Date.Format("2006-01-02"),
strconv.FormatInt(s.GetTotal, 10),
s.Wallet,
}
return record

View File

@ -55,8 +55,6 @@ type DB interface {
Update(ctx context.Context, value *pb.Node) error
// Delete deletes node based on id
Delete(ctx context.Context, id storj.NodeID) error
// GetWalletAddress gets the node's wallet address
GetWalletAddress(ctx context.Context, id storj.NodeID) (string, error)
}
// Cache is used to store overlay data in Redis

View File

@ -183,11 +183,6 @@ read one (
where overlay_cache_node.node_id = ?
)
read one (
select overlay_cache_node.operator_wallet
where overlay_cache_node.node_id = ?
)
read limitoffset (
select overlay_cache_node
where overlay_cache_node.node_id >= ?

View File

@ -2528,10 +2528,6 @@ type Id_Row struct {
Id []byte
}
type OperatorWallet_Row struct {
OperatorWallet string
}
type Value_Row struct {
Value time.Time
}
@ -3269,27 +3265,6 @@ func (obj *postgresImpl) Get_OverlayCacheNode_By_NodeId(ctx context.Context,
}
func (obj *postgresImpl) Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx context.Context,
overlay_cache_node_node_id OverlayCacheNode_NodeId_Field) (
row *OperatorWallet_Row, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT overlay_cache_nodes.operator_wallet FROM overlay_cache_nodes WHERE overlay_cache_nodes.node_id = ?")
var __values []interface{}
__values = append(__values, overlay_cache_node_node_id.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
row = &OperatorWallet_Row{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&row.OperatorWallet)
if err != nil {
return nil, obj.makeErr(err)
}
return row, nil
}
func (obj *postgresImpl) Limited_OverlayCacheNode_By_NodeId_GreaterOrEqual(ctx context.Context,
overlay_cache_node_node_id_greater_or_equal OverlayCacheNode_NodeId_Field,
limit int, offset int64) (
@ -5354,27 +5329,6 @@ func (obj *sqlite3Impl) Get_OverlayCacheNode_By_NodeId(ctx context.Context,
}
func (obj *sqlite3Impl) Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx context.Context,
overlay_cache_node_node_id OverlayCacheNode_NodeId_Field) (
row *OperatorWallet_Row, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT overlay_cache_nodes.operator_wallet FROM overlay_cache_nodes WHERE overlay_cache_nodes.node_id = ?")
var __values []interface{}
__values = append(__values, overlay_cache_node_node_id.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
row = &OperatorWallet_Row{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&row.OperatorWallet)
if err != nil {
return nil, obj.makeErr(err)
}
return row, nil
}
func (obj *sqlite3Impl) Limited_OverlayCacheNode_By_NodeId_GreaterOrEqual(ctx context.Context,
overlay_cache_node_node_id_greater_or_equal OverlayCacheNode_NodeId_Field,
limit int, offset int64) (
@ -7529,16 +7483,6 @@ func (rx *Rx) Get_OverlayCacheNode_By_NodeId(ctx context.Context,
return tx.Get_OverlayCacheNode_By_NodeId(ctx, overlay_cache_node_node_id)
}
func (rx *Rx) Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx context.Context,
overlay_cache_node_node_id OverlayCacheNode_NodeId_Field) (
row *OperatorWallet_Row, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx, overlay_cache_node_node_id)
}
func (rx *Rx) Get_Project_By_Id(ctx context.Context,
project_id Project_Id_Field) (
project *Project, err error) {
@ -7924,10 +7868,6 @@ type Methods interface {
overlay_cache_node_node_id OverlayCacheNode_NodeId_Field) (
overlay_cache_node *OverlayCacheNode, err error)
Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx context.Context,
overlay_cache_node_node_id OverlayCacheNode_NodeId_Field) (
row *OperatorWallet_Row, err error)
Get_Project_By_Id(ctx context.Context,
project_id Project_Id_Field) (
project *Project, err error)

View File

@ -468,13 +468,6 @@ func (m *lockedOverlayCache) GetAll(ctx context.Context, nodeIDs storj.NodeIDLis
return m.db.GetAll(ctx, nodeIDs)
}
// GetWalletAddress gets the node's wallet address
func (m *lockedOverlayCache) GetWalletAddress(ctx context.Context, id storj.NodeID) (string, error) {
m.Lock()
defer m.Unlock()
return m.db.GetWalletAddress(ctx, id)
}
// List lists nodes starting from cursor
func (m *lockedOverlayCache) List(ctx context.Context, cursor storj.NodeID, limit int) ([]*pb.Node, error) {
m.Lock()

View File

@ -350,12 +350,3 @@ func convertOverlayNode(info *dbx.OverlayCacheNode) (*pb.Node, error) {
return node, nil
}
//GetWalletAddress gets the node's wallet address
func (cache *overlaycache) GetWalletAddress(ctx context.Context, id storj.NodeID) (string, error) {
w, err := cache.db.Get_OverlayCacheNode_OperatorWallet_By_NodeId(ctx, dbx.OverlayCacheNode_NodeId(id.Bytes()))
if err != nil {
return "", err
}
return w.OperatorWallet, nil
}