storagenode/payouts: Distributed added to paystubs
Change-Id: I02ba1f681be84765a0a5dae7af17d2a6674e7cca
This commit is contained in:
parent
cc0d88f9c3
commit
e383722812
@ -95,6 +95,7 @@ func (endpoint *Endpoint) GetPaystub(ctx context.Context, satelliteID storj.Node
|
||||
Owed: resp.Owed,
|
||||
Disposed: resp.Disposed,
|
||||
Paid: resp.Paid,
|
||||
Distributed: resp.Distributed,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -138,6 +139,7 @@ func (endpoint *Endpoint) GetAllPaystubs(ctx context.Context, satelliteID storj.
|
||||
Owed: resp.Paystub[i].Owed,
|
||||
Disposed: resp.Paystub[i].Disposed,
|
||||
Paid: resp.Paystub[i].Paid,
|
||||
Distributed: resp.Paystub[i].Distributed,
|
||||
}
|
||||
|
||||
payStubs = append(payStubs, paystub)
|
||||
|
@ -64,6 +64,7 @@ type PayStub struct {
|
||||
Owed int64 `json:"owed"`
|
||||
Disposed int64 `json:"disposed"`
|
||||
Paid int64 `json:"paid"`
|
||||
Distributed int64 `json:"distributed"`
|
||||
}
|
||||
|
||||
// HoldForPeriod is node's held amount for period.
|
||||
|
@ -1893,6 +1893,14 @@ func (db *DB) Migration(ctx context.Context) *migrate.Migration {
|
||||
return nil
|
||||
}),
|
||||
},
|
||||
{
|
||||
DB: &db.payoutDB.DB,
|
||||
Description: "Add distributed field to paystubs table",
|
||||
Version: 49,
|
||||
Action: migrate.SQL{
|
||||
`ALTER TABLE paystubs ADD COLUMN distributed bigint`,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -53,8 +53,9 @@ func (db *payoutDB) StorePayStub(ctx context.Context, paystub payouts.PayStub) (
|
||||
held,
|
||||
owed,
|
||||
disposed,
|
||||
paid
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
|
||||
paid,
|
||||
distributed
|
||||
) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`
|
||||
|
||||
_, err = db.ExecContext(ctx, query,
|
||||
paystub.Period,
|
||||
@ -78,6 +79,7 @@ func (db *payoutDB) StorePayStub(ctx context.Context, paystub payouts.PayStub) (
|
||||
paystub.Owed,
|
||||
paystub.Disposed,
|
||||
paystub.Paid,
|
||||
paystub.Distributed,
|
||||
)
|
||||
|
||||
return ErrPayout.Wrap(err)
|
||||
@ -111,7 +113,8 @@ func (db *payoutDB) GetPayStub(ctx context.Context, satelliteID storj.NodeID, pe
|
||||
held,
|
||||
owed,
|
||||
disposed,
|
||||
paid
|
||||
paid,
|
||||
distributed
|
||||
FROM paystubs WHERE satellite_id = ? AND period = ?`,
|
||||
satelliteID, period,
|
||||
)
|
||||
@ -136,6 +139,7 @@ func (db *payoutDB) GetPayStub(ctx context.Context, satelliteID storj.NodeID, pe
|
||||
&result.Owed,
|
||||
&result.Disposed,
|
||||
&result.Paid,
|
||||
&result.Distributed,
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
@ -171,7 +175,8 @@ func (db *payoutDB) AllPayStubs(ctx context.Context, period string) (_ []payouts
|
||||
held,
|
||||
owed,
|
||||
disposed,
|
||||
paid
|
||||
paid,
|
||||
distributed
|
||||
FROM paystubs WHERE period = ?`
|
||||
|
||||
rows, err := db.QueryContext(ctx, query, period)
|
||||
@ -206,6 +211,7 @@ func (db *payoutDB) AllPayStubs(ctx context.Context, period string) (_ []payouts
|
||||
&paystub.Owed,
|
||||
&paystub.Disposed,
|
||||
&paystub.Paid,
|
||||
&paystub.Distributed,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, ErrPayout.Wrap(err)
|
||||
|
@ -159,6 +159,11 @@ func Schema() map[string]*dbschema.Schema {
|
||||
Type: "bigint",
|
||||
IsNullable: false,
|
||||
},
|
||||
&dbschema.Column{
|
||||
Name: "distributed",
|
||||
Type: "bigint",
|
||||
IsNullable: true,
|
||||
},
|
||||
&dbschema.Column{
|
||||
Name: "held",
|
||||
Type: "bigint",
|
||||
@ -719,3 +724,4 @@ func Schema() map[string]*dbschema.Schema {
|
||||
"used_serial": &dbschema.Schema{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ var States = MultiDBStates{
|
||||
&v46,
|
||||
&v47,
|
||||
&v48,
|
||||
&v49,
|
||||
},
|
||||
}
|
||||
|
||||
|
63
storagenode/storagenodedb/testdata/v49.go
vendored
Normal file
63
storagenode/storagenodedb/testdata/v49.go
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright (C) 2021 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package testdata
|
||||
|
||||
import "storj.io/storj/storagenode/storagenodedb"
|
||||
|
||||
var v49 = MultiDBState{
|
||||
Version: 49,
|
||||
DBStates: DBStates{
|
||||
storagenodedb.UsedSerialsDBName: v47.DBStates[storagenodedb.UsedSerialsDBName],
|
||||
storagenodedb.StorageUsageDBName: v47.DBStates[storagenodedb.StorageUsageDBName],
|
||||
storagenodedb.ReputationDBName: v48.DBStates[storagenodedb.ReputationDBName],
|
||||
storagenodedb.PieceSpaceUsedDBName: v47.DBStates[storagenodedb.PieceSpaceUsedDBName],
|
||||
storagenodedb.PieceInfoDBName: v47.DBStates[storagenodedb.PieceInfoDBName],
|
||||
storagenodedb.PieceExpirationDBName: v47.DBStates[storagenodedb.PieceExpirationDBName],
|
||||
storagenodedb.OrdersDBName: v47.DBStates[storagenodedb.OrdersDBName],
|
||||
storagenodedb.BandwidthDBName: v47.DBStates[storagenodedb.BandwidthDBName],
|
||||
storagenodedb.SatellitesDBName: v47.DBStates[storagenodedb.SatellitesDBName],
|
||||
storagenodedb.DeprecatedInfoDBName: v47.DBStates[storagenodedb.DeprecatedInfoDBName],
|
||||
storagenodedb.NotificationsDBName: v47.DBStates[storagenodedb.NotificationsDBName],
|
||||
storagenodedb.HeldAmountDBName: &DBState{
|
||||
SQL: `
|
||||
-- tables to hold payments and paystub data
|
||||
CREATE TABLE paystubs (
|
||||
period text NOT NULL,
|
||||
satellite_id bytea NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
codes text NOT NULL,
|
||||
usage_at_rest double precision NOT NULL,
|
||||
usage_get bigint NOT NULL,
|
||||
usage_put bigint NOT NULL,
|
||||
usage_get_repair bigint NOT NULL,
|
||||
usage_put_repair bigint NOT NULL,
|
||||
usage_get_audit bigint NOT NULL,
|
||||
comp_at_rest bigint NOT NULL,
|
||||
comp_get bigint NOT NULL,
|
||||
comp_put bigint NOT NULL,
|
||||
comp_get_repair bigint NOT NULL,
|
||||
comp_put_repair bigint NOT NULL,
|
||||
comp_get_audit bigint NOT NULL,
|
||||
surge_percent bigint NOT NULL,
|
||||
held bigint NOT NULL,
|
||||
owed bigint NOT NULL,
|
||||
disposed bigint NOT NULL,
|
||||
paid bigint NOT NULL,
|
||||
distributed bigint,
|
||||
PRIMARY KEY ( period, satellite_id )
|
||||
);
|
||||
CREATE TABLE payments (
|
||||
id bigserial NOT NULL,
|
||||
created_at timestamp NOT NULL,
|
||||
satellite_id bytea NOT NULL,
|
||||
period text,
|
||||
amount bigint NOT NULL,
|
||||
receipt text,
|
||||
notes text,
|
||||
PRIMARY KEY ( id )
|
||||
);`,
|
||||
},
|
||||
storagenodedb.PricingDBName: v47.DBStates[storagenodedb.PricingDBName],
|
||||
storagenodedb.APIKeysDBName: v47.DBStates[storagenodedb.APIKeysDBName]},
|
||||
}
|
Loading…
Reference in New Issue
Block a user