rollup query (#1056)

* implemention notes

* more notes

* starting rollup query

* not working yet

* fixed build

* fixed cfg bug

* change context cancelled errs to debugs

* using byte hours for at rest tally

* revert changes to go.mod

* comment fixes

* prevent double recording tallies in rollup

* linting

* stop leaking dbx

* nodeid changes

* fix build
This commit is contained in:
Bill Thorp 2019-01-16 14:30:33 -05:00 committed by Cameron
parent 62a7088133
commit 342dc857f5
14 changed files with 523 additions and 416 deletions

View File

@ -18,4 +18,6 @@ const (
LastAtRestTally = "LastAtRestTally"
// LastBandwidthTally represents the accounting timestamp for the bandwidth allocation query
LastBandwidthTally = "LastBandwidthTally"
// LastRollup represents the accounting timestamp for rollup calculations
LastRollup = "LastRollup"
)

View File

@ -11,8 +11,34 @@ import (
"storj.io/storj/pkg/storj"
)
//BWTally is a convience alias
type BWTally [pb.PayerBandwidthAllocation_PUT_REPAIR + 1]map[string]int64
//BWTally is a convenience alias
type BWTally [pb.PayerBandwidthAllocation_PUT_REPAIR + 1]map[storj.NodeID]int64
//RollupStats is a convenience alias
type RollupStats map[time.Time]map[storj.NodeID]*Rollup
//Raw mirrors dbx.AccountingRaw, allowing us to use that struct without leaking dbx
type Raw struct {
ID int64
NodeID storj.NodeID
IntervalEndTime time.Time
DataTotal float64
DataType int
CreatedAt time.Time
}
//Rollup mirrors dbx.AccountingRollup, allowing us to use that struct without leaking dbx
type Rollup struct {
ID int64
NodeID storj.NodeID
StartTime time.Time
PutTotal int64
GetTotal int64
GetAuditTotal int64
GetRepairTotal int64
PutRepairTotal int64
AtRestTotal float64
}
// DB stores information about bandwidth usage
type DB interface {
@ -21,5 +47,11 @@ type DB interface {
// SaveBWRaw records raw sums of agreement values to the database and updates the LastRawTime.
SaveBWRaw(ctx context.Context, latestBwa time.Time, bwTotals BWTally) error
// SaveAtRestRaw records raw tallies of at-rest-data.
SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]int64) error
SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) error
// GetRaw retrieves all raw tallies
GetRaw(ctx context.Context) ([]*Raw, error)
// GetRawSince r retrieves all raw tallies sinces
GetRawSince(ctx context.Context, latestRollup time.Time) ([]*Raw, error)
// SaveRollup records raw tallies of at rest data to the database
SaveRollup(ctx context.Context, latestTally time.Time, stats RollupStats) error
}

View File

@ -16,7 +16,7 @@ import (
// Config contains configurable values for rollup
type Config struct {
Interval time.Duration `help:"how frequently rollup should run" default:"30s"`
Interval time.Duration `help:"how frequently rollup should run" default:"1h"`
}
// Initialize a rollup struct
@ -39,7 +39,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
go func() {
if err := rollup.Run(ctx); err != nil {
defer cancel()
zap.L().Error("Error running rollup", zap.Error(err))
zap.L().Debug("Rollup is shutting down", zap.Error(err))
}
}()

View File

@ -5,14 +5,16 @@ package rollup
import (
"context"
"fmt"
"time"
"go.uber.org/zap"
"storj.io/storj/pkg/accounting"
"storj.io/storj/pkg/storj"
)
// Rollup is the service for totalling data on storage nodes for 1, 7, 30 day intervals
// Rollup is the service for totalling data on storage nodes on daily intervals
type Rollup interface {
Run(ctx context.Context) error
}
@ -34,13 +36,11 @@ func newRollup(logger *zap.Logger, db accounting.DB, interval time.Duration) *ro
// Run the rollup loop
func (r *rollup) Run(ctx context.Context) (err error) {
defer mon.Task()(&ctx)(&err)
for {
err = r.Query(ctx)
if err != nil {
r.logger.Error("Query failed", zap.Error(err))
}
select {
case <-r.ticker.C: // wait for the next interval to happen
case <-ctx.Done(): // or the rollup is canceled via context
@ -50,6 +50,62 @@ func (r *rollup) Run(ctx context.Context) (err error) {
}
func (r *rollup) Query(ctx context.Context) error {
//TODO
return nil
//only rollup new things - get LastRollup
var latestTally time.Time
lastRollup, isNil, err := r.db.LastRawTime(ctx, accounting.LastRollup)
if err != nil {
return Error.Wrap(err)
}
var tallies []*accounting.Raw
if isNil {
r.logger.Info("Rollup found no existing raw tally data")
tallies, err = r.db.GetRaw(ctx)
} else {
tallies, err = r.db.GetRawSince(ctx, lastRollup)
}
if err != nil {
return Error.Wrap(err)
}
if len(tallies) == 0 {
r.logger.Info("Rollup found no new tallies")
return nil
}
//loop through tallies and build rollup
rollupStats := make(accounting.RollupStats)
for _, tallyRow := range tallies {
node := tallyRow.NodeID
if tallyRow.CreatedAt.After(latestTally) {
latestTally = tallyRow.CreatedAt
}
//create or get AccoutingRollup
iDay := tallyRow.IntervalEndTime
iDay = time.Date(iDay.Year(), iDay.Month(), iDay.Day(), 0, 0, 0, 0, iDay.Location())
if rollupStats[iDay] == nil {
rollupStats[iDay] = make(map[storj.NodeID]*accounting.Rollup)
}
if rollupStats[iDay][node] == nil {
rollupStats[iDay][node] = &accounting.Rollup{NodeID: node, StartTime: iDay}
}
//increment Rollups
switch tallyRow.DataType {
case accounting.BandwidthPut:
rollupStats[iDay][node].PutTotal += int64(tallyRow.DataTotal)
case accounting.BandwidthGet:
rollupStats[iDay][node].GetTotal += int64(tallyRow.DataTotal)
case accounting.BandwidthGetAudit:
rollupStats[iDay][node].GetAuditTotal += int64(tallyRow.DataTotal)
case accounting.BandwidthGetRepair:
rollupStats[iDay][node].GetRepairTotal += int64(tallyRow.DataTotal)
case accounting.BandwidthPutRepair:
rollupStats[iDay][node].PutRepairTotal += int64(tallyRow.DataTotal)
case accounting.AtRest:
rollupStats[iDay][node].AtRestTotal += tallyRow.DataTotal
default:
return Error.Wrap(fmt.Errorf("Bad tally datatype in rollup : %d", tallyRow.DataType))
}
}
//remove the latest day (which we cannot know is complete), then push to DB
latestTally = time.Date(latestTally.Year(), latestTally.Month(), latestTally.Day(), 0, 0, 0, 0, latestTally.Location())
delete(rollupStats, latestTally)
return Error.Wrap(r.db.SaveRollup(ctx, latestTally, rollupStats))
}

View File

@ -53,7 +53,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
go func() {
if err := tally.Run(ctx); err != nil {
defer cancel()
zap.L().Error("Error running tally", zap.Error(err))
zap.L().Debug("Tally is shutting down", zap.Error(err))
}
}()

View File

@ -71,7 +71,13 @@ func (t *tally) Run(ctx context.Context) (err error) {
// the amount of at-rest data stored on each respective node
func (t *tally) calculateAtRestData(ctx context.Context) (err error) {
defer mon.Task()(&ctx)(&err)
var nodeData = make(map[storj.NodeID]int64)
latestTally, isNil, err := t.accountingDB.LastRawTime(ctx, accounting.LastAtRestTally)
if err != nil {
return Error.Wrap(err)
}
var nodeData = make(map[storj.NodeID]float64)
err = t.pointerdb.Iterate(ctx, &pb.IterateRequest{Recurse: true},
func(it storage.Iterator) error {
var item storage.ListItem
@ -103,27 +109,25 @@ func (t *tally) calculateAtRestData(ctx context.Context) (err error) {
}
pieceSize := segmentSize / int64(minReq)
for _, piece := range pieces {
nodeData[piece.NodeId] += pieceSize
nodeData[piece.NodeId] += float64(pieceSize)
}
}
return nil
},
)
if err != nil {
return Error.Wrap(err)
}
if len(nodeData) == 0 {
return nil
}
latestTally, isNil, err := t.accountingDB.LastRawTime(ctx, accounting.LastAtRestTally)
if err != nil {
return Error.Wrap(err)
}
if err != nil {
return Error.Wrap(err)
//store byte hours, not just bytes
numHours := 1.0 //todo: something more considered?
if !isNil {
numHours = time.Now().UTC().Sub(latestTally).Hours()
}
if isNil {
latestTally = time.Now().UTC()
for k := range nodeData {
nodeData[k] *= numHours
}
return Error.Wrap(t.accountingDB.SaveAtRestRaw(ctx, latestTally, nodeData))
}
@ -146,7 +150,6 @@ func (t *tally) queryBW(ctx context.Context) error {
if err != nil {
return Error.Wrap(err)
}
if len(bwAgreements) == 0 {
t.logger.Info("Tally found no new bandwidth allocations")
return nil
@ -155,7 +158,7 @@ func (t *tally) queryBW(ctx context.Context) error {
// sum totals by node id ... todo: add nodeid as SQL column so DB can do this?
var bwTotals accounting.BWTally
for i := range bwTotals {
bwTotals[i] = make(map[string]int64)
bwTotals[i] = make(map[storj.NodeID]int64)
}
var latestBwa time.Time
for _, baRow := range bwAgreements {
@ -168,12 +171,10 @@ func (t *tally) queryBW(ctx context.Context) error {
if err := proto.Unmarshal(rbad.GetPayerAllocation().GetData(), pbad); err != nil {
return err
}
if baRow.CreatedAt.After(latestBwa) {
latestBwa = baRow.CreatedAt
}
bwTotals[pbad.GetAction()][rbad.StorageNodeId.String()] += rbad.GetTotal()
bwTotals[pbad.GetAction()][rbad.StorageNodeId] += rbad.GetTotal()
}
return Error.Wrap(t.accountingDB.SaveBWRaw(ctx, lastBwTally, bwTotals))
}

View File

@ -54,7 +54,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
go func() {
if err := check.Run(ctx); err != nil {
defer cancel()
zap.L().Error("Error running checker", zap.Error(err))
zap.L().Debug("Checker is shutting down", zap.Error(err))
}
}()

View File

@ -50,7 +50,7 @@ func (c Config) Run(ctx context.Context, server *provider.Provider) (err error)
go func() {
if err := service.Run(ctx); err != nil {
defer cancel()
zap.L().Error("Error running repair service", zap.Error(err))
zap.L().Debug("Repair service is shutting down", zap.Error(err))
}
}()

View File

@ -31,12 +31,7 @@ func (db *accountingDB) LastRawTime(ctx context.Context, timestampType string) (
// and updates the LastRawTime
func (db *accountingDB) SaveBWRaw(ctx context.Context, latestBwa time.Time, bwTotals accounting.BWTally) (err error) {
// We use the latest bandwidth agreement value of a batch of records as the start of the next batch
// This enables us to not use:
// 1) local time (which may deviate from DB time)
// 2) absolute time intervals (where in processing time could exceed the interval, causing issues)
// 3) per-node latest times (which simply would require a lot more work, albeit more precise)
// Any change in these assumptions would result in a change to this function
// in particular, we should consider finding the sum of bwagreements using SQL sum() direct against the bwa table
// todo: consider finding the sum of bwagreements using SQL sum() direct against the bwa table
if len(bwTotals) == 0 {
return Error.New("In SaveBWRaw with empty bwtotals")
}
@ -55,9 +50,9 @@ func (db *accountingDB) SaveBWRaw(ctx context.Context, latestBwa time.Time, bwTo
//create a granular record per node id
for actionType, bwActionTotals := range bwTotals {
for k, v := range bwActionTotals {
nID := dbx.AccountingRaw_NodeId(k)
nID := dbx.AccountingRaw_NodeId(k.Bytes())
end := dbx.AccountingRaw_IntervalEndTime(latestBwa)
total := dbx.AccountingRaw_DataTotal(v)
total := dbx.AccountingRaw_DataTotal(float64(v))
dataType := dbx.AccountingRaw_DataType(actionType)
_, err = tx.Create_AccountingRaw(ctx, nID, end, total, dataType)
if err != nil {
@ -72,7 +67,7 @@ func (db *accountingDB) SaveBWRaw(ctx context.Context, latestBwa time.Time, bwTo
}
// SaveAtRestRaw records raw tallies of at rest data to the database
func (db *accountingDB) SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]int64) error {
func (db *accountingDB) SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) error {
if len(nodeData) == 0 {
return Error.New("In SaveAtRestRaw with empty nodeData")
}
@ -88,7 +83,7 @@ func (db *accountingDB) SaveAtRestRaw(ctx context.Context, latestTally time.Time
}
}()
for k, v := range nodeData {
nID := dbx.AccountingRaw_NodeId(k.String())
nID := dbx.AccountingRaw_NodeId(k.Bytes())
end := dbx.AccountingRaw_IntervalEndTime(latestTally)
total := dbx.AccountingRaw_DataTotal(v)
dataType := dbx.AccountingRaw_DataType(accounting.AtRest)
@ -101,3 +96,82 @@ func (db *accountingDB) SaveAtRestRaw(ctx context.Context, latestTally time.Time
_, err = tx.Update_AccountingTimestamps_By_Name(ctx, dbx.AccountingTimestamps_Name(accounting.LastAtRestTally), update)
return Error.Wrap(err)
}
// GetRaw retrieves all raw tallies
func (db *accountingDB) GetRaw(ctx context.Context) ([]*accounting.Raw, error) {
raws, err := db.db.All_AccountingRaw(ctx)
out := make([]*accounting.Raw, len(raws))
for i, r := range raws {
nodeID, err := storj.NodeIDFromBytes(r.NodeId)
if err != nil {
return nil, Error.Wrap(err)
}
out[i] = &accounting.Raw{
ID: r.Id,
NodeID: nodeID,
IntervalEndTime: r.IntervalEndTime,
DataTotal: r.DataTotal,
DataType: r.DataType,
CreatedAt: r.CreatedAt,
}
}
return out, Error.Wrap(err)
}
// GetRawSince r retrieves all raw tallies sinces
func (db *accountingDB) GetRawSince(ctx context.Context, latestRollup time.Time) ([]*accounting.Raw, error) {
raws, err := db.db.All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx, dbx.AccountingRaw_IntervalEndTime(latestRollup))
out := make([]*accounting.Raw, len(raws))
for i, r := range raws {
nodeID, err := storj.NodeIDFromBytes(r.NodeId)
if err != nil {
return nil, Error.Wrap(err)
}
out[i] = &accounting.Raw{
ID: r.Id,
NodeID: nodeID,
IntervalEndTime: r.IntervalEndTime,
DataTotal: r.DataTotal,
DataType: r.DataType,
CreatedAt: r.CreatedAt,
}
}
return out, Error.Wrap(err)
}
// SaveRollup records raw tallies of at rest data to the database
func (db *accountingDB) SaveRollup(ctx context.Context, latestRollup time.Time, stats accounting.RollupStats) error {
if len(stats) == 0 {
return Error.New("In SaveRollup with empty nodeData")
}
tx, err := db.db.Open(ctx)
if err != nil {
return Error.Wrap(err)
}
defer func() {
if err == nil {
err = tx.Commit()
} else {
err = utils.CombineErrors(err, tx.Rollback())
}
}()
for _, arsByDate := range stats {
for _, ar := range arsByDate {
nID := dbx.AccountingRollup_NodeId(ar.NodeID.Bytes())
start := dbx.AccountingRollup_StartTime(ar.StartTime)
put := dbx.AccountingRollup_PutTotal(ar.PutTotal)
get := dbx.AccountingRollup_GetTotal(ar.GetTotal)
audit := dbx.AccountingRollup_GetAuditTotal(ar.GetAuditTotal)
getRepair := dbx.AccountingRollup_GetRepairTotal(ar.GetRepairTotal)
putRepair := dbx.AccountingRollup_PutRepairTotal(ar.PutRepairTotal)
atRest := dbx.AccountingRollup_AtRestTotal(ar.AtRestTotal)
_, err = tx.Create_AccountingRollup(ctx, nID, start, put, get, audit, getRepair, putRepair, atRest)
if err != nil {
return Error.Wrap(err)
}
}
}
update := dbx.AccountingTimestamps_Update_Fields{Value: dbx.AccountingTimestamps_Value(latestRollup)}
_, err = tx.Update_AccountingTimestamps_By_Name(ctx, dbx.AccountingTimestamps_Name(accounting.LastRollup), update)
return Error.Wrap(err)
}

View File

@ -77,17 +77,18 @@ read scalar (
model accounting_rollup (
key id
field id serial64
field node_id text
field start_time timestamp
field interval int64
field data_type int
field created_at timestamp ( autoinsert )
field updated_at timestamp ( autoinsert, autoupdate )
field id serial64
field node_id blob
field start_time timestamp
field put_total int64
field get_total int64
field get_audit_total int64
field get_repair_total int64
field put_repair_total int64
field at_rest_total float64
)
create accounting_rollup ( )
update accounting_rollup ( where accounting_rollup.id = ? )
delete accounting_rollup ( where accounting_rollup.id = ? )
read one (
@ -97,23 +98,21 @@ read one (
read all (
select accounting_rollup
where accounting_rollup.node_id = ?
where accounting_rollup.start_time >= ?
)
model accounting_raw (
key id
field id serial64
field node_id text
field node_id blob
field interval_end_time timestamp
field data_total int64
field data_total float64
field data_type int
field created_at timestamp ( autoinsert )
field updated_at timestamp ( autoinsert, autoupdate )
)
create accounting_raw ( )
update accounting_raw ( where accounting_raw.id = ? )
delete accounting_raw ( where accounting_raw.id = ? )
read one (
@ -123,7 +122,11 @@ read one (
read all (
select accounting_raw
where accounting_raw.node_id = ?
)
read all (
select accounting_raw
where accounting_raw.interval_end_time >= ?
)
//--- statdb ---//

View File

@ -275,22 +275,23 @@ func newpostgres(db *DB) *postgresDB {
func (obj *postgresDB) Schema() string {
return `CREATE TABLE accounting_raws (
id bigserial NOT NULL,
node_id text NOT NULL,
node_id bytea NOT NULL,
interval_end_time timestamp with time zone NOT NULL,
data_total bigint NOT NULL,
data_total double precision NOT NULL,
data_type integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_rollups (
id bigserial NOT NULL,
node_id text NOT NULL,
node_id bytea NOT NULL,
start_time timestamp with time zone NOT NULL,
interval bigint NOT NULL,
data_type integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
put_total bigint NOT NULL,
get_total bigint NOT NULL,
get_audit_total bigint NOT NULL,
get_repair_total bigint NOT NULL,
put_repair_total bigint NOT NULL,
at_rest_total double precision NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_timestamps (
@ -416,22 +417,23 @@ func newsqlite3(db *DB) *sqlite3DB {
func (obj *sqlite3DB) Schema() string {
return `CREATE TABLE accounting_raws (
id INTEGER NOT NULL,
node_id TEXT NOT NULL,
node_id BLOB NOT NULL,
interval_end_time TIMESTAMP NOT NULL,
data_total INTEGER NOT NULL,
data_total REAL NOT NULL,
data_type INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_rollups (
id INTEGER NOT NULL,
node_id TEXT NOT NULL,
node_id BLOB NOT NULL,
start_time TIMESTAMP NOT NULL,
interval INTEGER NOT NULL,
data_type INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
put_total INTEGER NOT NULL,
get_total INTEGER NOT NULL,
get_audit_total INTEGER NOT NULL,
get_repair_total INTEGER NOT NULL,
put_repair_total INTEGER NOT NULL,
at_rest_total REAL NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_timestamps (
@ -556,12 +558,11 @@ nextval:
type AccountingRaw struct {
Id int64
NodeId string
NodeId []byte
IntervalEndTime time.Time
DataTotal int64
DataTotal float64
DataType int
CreatedAt time.Time
UpdatedAt time.Time
}
func (AccountingRaw) _Table() string { return "accounting_raws" }
@ -591,10 +592,10 @@ func (AccountingRaw_Id_Field) _Column() string { return "id" }
type AccountingRaw_NodeId_Field struct {
_set bool
_null bool
_value string
_value []byte
}
func AccountingRaw_NodeId(v string) AccountingRaw_NodeId_Field {
func AccountingRaw_NodeId(v []byte) AccountingRaw_NodeId_Field {
return AccountingRaw_NodeId_Field{_set: true, _value: v}
}
@ -629,10 +630,10 @@ func (AccountingRaw_IntervalEndTime_Field) _Column() string { return "interval_e
type AccountingRaw_DataTotal_Field struct {
_set bool
_null bool
_value int64
_value float64
}
func AccountingRaw_DataTotal(v int64) AccountingRaw_DataTotal_Field {
func AccountingRaw_DataTotal(v float64) AccountingRaw_DataTotal_Field {
return AccountingRaw_DataTotal_Field{_set: true, _value: v}
}
@ -683,33 +684,16 @@ func (f AccountingRaw_CreatedAt_Field) value() interface{} {
func (AccountingRaw_CreatedAt_Field) _Column() string { return "created_at" }
type AccountingRaw_UpdatedAt_Field struct {
_set bool
_null bool
_value time.Time
}
func AccountingRaw_UpdatedAt(v time.Time) AccountingRaw_UpdatedAt_Field {
return AccountingRaw_UpdatedAt_Field{_set: true, _value: v}
}
func (f AccountingRaw_UpdatedAt_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRaw_UpdatedAt_Field) _Column() string { return "updated_at" }
type AccountingRollup struct {
Id int64
NodeId string
StartTime time.Time
Interval int64
DataType int
CreatedAt time.Time
UpdatedAt time.Time
Id int64
NodeId []byte
StartTime time.Time
PutTotal int64
GetTotal int64
GetAuditTotal int64
GetRepairTotal int64
PutRepairTotal int64
AtRestTotal float64
}
func (AccountingRollup) _Table() string { return "accounting_rollups" }
@ -739,10 +723,10 @@ func (AccountingRollup_Id_Field) _Column() string { return "id" }
type AccountingRollup_NodeId_Field struct {
_set bool
_null bool
_value string
_value []byte
}
func AccountingRollup_NodeId(v string) AccountingRollup_NodeId_Field {
func AccountingRollup_NodeId(v []byte) AccountingRollup_NodeId_Field {
return AccountingRollup_NodeId_Field{_set: true, _value: v}
}
@ -774,81 +758,119 @@ func (f AccountingRollup_StartTime_Field) value() interface{} {
func (AccountingRollup_StartTime_Field) _Column() string { return "start_time" }
type AccountingRollup_Interval_Field struct {
type AccountingRollup_PutTotal_Field struct {
_set bool
_null bool
_value int64
}
func AccountingRollup_Interval(v int64) AccountingRollup_Interval_Field {
return AccountingRollup_Interval_Field{_set: true, _value: v}
func AccountingRollup_PutTotal(v int64) AccountingRollup_PutTotal_Field {
return AccountingRollup_PutTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_Interval_Field) value() interface{} {
func (f AccountingRollup_PutTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_Interval_Field) _Column() string { return "interval" }
func (AccountingRollup_PutTotal_Field) _Column() string { return "put_total" }
type AccountingRollup_DataType_Field struct {
type AccountingRollup_GetTotal_Field struct {
_set bool
_null bool
_value int
_value int64
}
func AccountingRollup_DataType(v int) AccountingRollup_DataType_Field {
return AccountingRollup_DataType_Field{_set: true, _value: v}
func AccountingRollup_GetTotal(v int64) AccountingRollup_GetTotal_Field {
return AccountingRollup_GetTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_DataType_Field) value() interface{} {
func (f AccountingRollup_GetTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_DataType_Field) _Column() string { return "data_type" }
func (AccountingRollup_GetTotal_Field) _Column() string { return "get_total" }
type AccountingRollup_CreatedAt_Field struct {
type AccountingRollup_GetAuditTotal_Field struct {
_set bool
_null bool
_value time.Time
_value int64
}
func AccountingRollup_CreatedAt(v time.Time) AccountingRollup_CreatedAt_Field {
return AccountingRollup_CreatedAt_Field{_set: true, _value: v}
func AccountingRollup_GetAuditTotal(v int64) AccountingRollup_GetAuditTotal_Field {
return AccountingRollup_GetAuditTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_CreatedAt_Field) value() interface{} {
func (f AccountingRollup_GetAuditTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_CreatedAt_Field) _Column() string { return "created_at" }
func (AccountingRollup_GetAuditTotal_Field) _Column() string { return "get_audit_total" }
type AccountingRollup_UpdatedAt_Field struct {
type AccountingRollup_GetRepairTotal_Field struct {
_set bool
_null bool
_value time.Time
_value int64
}
func AccountingRollup_UpdatedAt(v time.Time) AccountingRollup_UpdatedAt_Field {
return AccountingRollup_UpdatedAt_Field{_set: true, _value: v}
func AccountingRollup_GetRepairTotal(v int64) AccountingRollup_GetRepairTotal_Field {
return AccountingRollup_GetRepairTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_UpdatedAt_Field) value() interface{} {
func (f AccountingRollup_GetRepairTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_UpdatedAt_Field) _Column() string { return "updated_at" }
func (AccountingRollup_GetRepairTotal_Field) _Column() string { return "get_repair_total" }
type AccountingRollup_PutRepairTotal_Field struct {
_set bool
_null bool
_value int64
}
func AccountingRollup_PutRepairTotal(v int64) AccountingRollup_PutRepairTotal_Field {
return AccountingRollup_PutRepairTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_PutRepairTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_PutRepairTotal_Field) _Column() string { return "put_repair_total" }
type AccountingRollup_AtRestTotal_Field struct {
_set bool
_null bool
_value float64
}
func AccountingRollup_AtRestTotal(v float64) AccountingRollup_AtRestTotal_Field {
return AccountingRollup_AtRestTotal_Field{_set: true, _value: v}
}
func (f AccountingRollup_AtRestTotal_Field) value() interface{} {
if !f._set || f._null {
return nil
}
return f._value
}
func (AccountingRollup_AtRestTotal_Field) _Column() string { return "at_rest_total" }
type AccountingTimestamps struct {
Name string
@ -1933,25 +1955,29 @@ func (obj *postgresImpl) Create_AccountingTimestamps(ctx context.Context,
func (obj *postgresImpl) Create_AccountingRollup(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field,
accounting_rollup_start_time AccountingRollup_StartTime_Field,
accounting_rollup_interval AccountingRollup_Interval_Field,
accounting_rollup_data_type AccountingRollup_DataType_Field) (
accounting_rollup_put_total AccountingRollup_PutTotal_Field,
accounting_rollup_get_total AccountingRollup_GetTotal_Field,
accounting_rollup_get_audit_total AccountingRollup_GetAuditTotal_Field,
accounting_rollup_get_repair_total AccountingRollup_GetRepairTotal_Field,
accounting_rollup_put_repair_total AccountingRollup_PutRepairTotal_Field,
accounting_rollup_at_rest_total AccountingRollup_AtRestTotal_Field) (
accounting_rollup *AccountingRollup, err error) {
__now := obj.db.Hooks.Now().UTC()
__node_id_val := accounting_rollup_node_id.value()
__start_time_val := accounting_rollup_start_time.value()
__interval_val := accounting_rollup_interval.value()
__data_type_val := accounting_rollup_data_type.value()
__created_at_val := __now
__updated_at_val := __now
__put_total_val := accounting_rollup_put_total.value()
__get_total_val := accounting_rollup_get_total.value()
__get_audit_total_val := accounting_rollup_get_audit_total.value()
__get_repair_total_val := accounting_rollup_get_repair_total.value()
__put_repair_total_val := accounting_rollup_put_repair_total.value()
__at_rest_total_val := accounting_rollup_at_rest_total.value()
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_rollups ( node_id, start_time, interval, data_type, created_at, updated_at ) VALUES ( ?, ?, ?, ?, ?, ? ) RETURNING accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at")
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_rollups ( node_id, start_time, put_total, get_total, get_audit_total, get_repair_total, put_repair_total, at_rest_total ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) RETURNING accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __node_id_val, __start_time_val, __interval_val, __data_type_val, __created_at_val, __updated_at_val)
obj.logStmt(__stmt, __node_id_val, __start_time_val, __put_total_val, __get_total_val, __get_audit_total_val, __get_repair_total_val, __put_repair_total_val, __at_rest_total_val)
accounting_rollup = &AccountingRollup{}
err = obj.driver.QueryRow(__stmt, __node_id_val, __start_time_val, __interval_val, __data_type_val, __created_at_val, __updated_at_val).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __node_id_val, __start_time_val, __put_total_val, __get_total_val, __get_audit_total_val, __get_repair_total_val, __put_repair_total_val, __at_rest_total_val).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -1972,15 +1998,14 @@ func (obj *postgresImpl) Create_AccountingRaw(ctx context.Context,
__data_total_val := accounting_raw_data_total.value()
__data_type_val := accounting_raw_data_type.value()
__created_at_val := __now
__updated_at_val := __now
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_raws ( node_id, interval_end_time, data_total, data_type, created_at, updated_at ) VALUES ( ?, ?, ?, ?, ?, ? ) RETURNING accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at")
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_raws ( node_id, interval_end_time, data_total, data_type, created_at ) VALUES ( ?, ?, ?, ?, ? ) RETURNING accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val, __updated_at_val)
obj.logStmt(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val)
accounting_raw = &AccountingRaw{}
err = obj.driver.QueryRow(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val, __updated_at_val).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -2259,7 +2284,7 @@ func (obj *postgresImpl) Get_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field) (
accounting_rollup *AccountingRollup, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE accounting_rollups.id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total FROM accounting_rollups WHERE accounting_rollups.id = ?")
var __values []interface{}
__values = append(__values, accounting_rollup_id.value())
@ -2268,7 +2293,7 @@ func (obj *postgresImpl) Get_AccountingRollup_By_Id(ctx context.Context,
obj.logStmt(__stmt, __values...)
accounting_rollup = &AccountingRollup{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -2276,14 +2301,14 @@ func (obj *postgresImpl) Get_AccountingRollup_By_Id(ctx context.Context,
}
func (obj *postgresImpl) All_AccountingRollup_By_NodeId(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field) (
func (obj *postgresImpl) All_AccountingRollup_By_StartTime_GreaterOrEqual(ctx context.Context,
accounting_rollup_start_time_greater_or_equal AccountingRollup_StartTime_Field) (
rows []*AccountingRollup, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE accounting_rollups.node_id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total FROM accounting_rollups WHERE accounting_rollups.start_time >= ?")
var __values []interface{}
__values = append(__values, accounting_rollup_node_id.value())
__values = append(__values, accounting_rollup_start_time_greater_or_equal.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
@ -2296,7 +2321,7 @@ func (obj *postgresImpl) All_AccountingRollup_By_NodeId(ctx context.Context,
for __rows.Next() {
accounting_rollup := &AccountingRollup{}
err = __rows.Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = __rows.Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -2313,7 +2338,7 @@ func (obj *postgresImpl) Get_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field) (
accounting_raw *AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE accounting_raws.id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws WHERE accounting_raws.id = ?")
var __values []interface{}
__values = append(__values, accounting_raw_id.value())
@ -2322,7 +2347,7 @@ func (obj *postgresImpl) Get_AccountingRaw_By_Id(ctx context.Context,
obj.logStmt(__stmt, __values...)
accounting_raw = &AccountingRaw{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -2330,14 +2355,13 @@ func (obj *postgresImpl) Get_AccountingRaw_By_Id(ctx context.Context,
}
func (obj *postgresImpl) All_AccountingRaw_By_NodeId(ctx context.Context,
accounting_raw_node_id AccountingRaw_NodeId_Field) (
func (obj *postgresImpl) All_AccountingRaw(ctx context.Context) (
rows []*AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE accounting_raws.node_id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws")
var __values []interface{}
__values = append(__values, accounting_raw_node_id.value())
__values = append(__values)
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
@ -2350,7 +2374,40 @@ func (obj *postgresImpl) All_AccountingRaw_By_NodeId(ctx context.Context,
for __rows.Next() {
accounting_raw := &AccountingRaw{}
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
rows = append(rows, accounting_raw)
}
if err := __rows.Err(); err != nil {
return nil, obj.makeErr(err)
}
return rows, nil
}
func (obj *postgresImpl) All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx context.Context,
accounting_raw_interval_end_time_greater_or_equal AccountingRaw_IntervalEndTime_Field) (
rows []*AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws WHERE accounting_raws.interval_end_time >= ?")
var __values []interface{}
__values = append(__values, accounting_raw_interval_end_time_greater_or_equal.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
__rows, err := obj.driver.Query(__stmt, __values...)
if err != nil {
return nil, obj.makeErr(err)
}
defer __rows.Close()
for __rows.Next() {
accounting_raw := &AccountingRaw{}
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -2605,78 +2662,6 @@ func (obj *postgresImpl) Update_AccountingTimestamps_By_Name(ctx context.Context
return accounting_timestamps, nil
}
func (obj *postgresImpl) Update_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field,
update AccountingRollup_Update_Fields) (
accounting_rollup *AccountingRollup, err error) {
var __sets = &__sqlbundle_Hole{}
var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE accounting_rollups SET "), __sets, __sqlbundle_Literal(" WHERE accounting_rollups.id = ? RETURNING accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at")}}
__sets_sql := __sqlbundle_Literals{Join: ", "}
var __values []interface{}
var __args []interface{}
__now := obj.db.Hooks.Now().UTC()
__values = append(__values, __now)
__sets_sql.SQLs = append(__sets_sql.SQLs, __sqlbundle_Literal("updated_at = ?"))
__args = append(__args, accounting_rollup_id.value())
__values = append(__values, __args...)
__sets.SQL = __sets_sql
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
accounting_rollup = &AccountingRollup{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, obj.makeErr(err)
}
return accounting_rollup, nil
}
func (obj *postgresImpl) Update_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field,
update AccountingRaw_Update_Fields) (
accounting_raw *AccountingRaw, err error) {
var __sets = &__sqlbundle_Hole{}
var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE accounting_raws SET "), __sets, __sqlbundle_Literal(" WHERE accounting_raws.id = ? RETURNING accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at")}}
__sets_sql := __sqlbundle_Literals{Join: ", "}
var __values []interface{}
var __args []interface{}
__now := obj.db.Hooks.Now().UTC()
__values = append(__values, __now)
__sets_sql.SQLs = append(__sets_sql.SQLs, __sqlbundle_Literal("updated_at = ?"))
__args = append(__args, accounting_raw_id.value())
__values = append(__values, __args...)
__sets.SQL = __sets_sql
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
accounting_raw = &AccountingRaw{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, obj.makeErr(err)
}
return accounting_raw, nil
}
func (obj *postgresImpl) Update_Node_By_Id(ctx context.Context,
node_id Node_Id_Field,
update Node_Update_Fields) (
@ -3237,24 +3222,28 @@ func (obj *sqlite3Impl) Create_AccountingTimestamps(ctx context.Context,
func (obj *sqlite3Impl) Create_AccountingRollup(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field,
accounting_rollup_start_time AccountingRollup_StartTime_Field,
accounting_rollup_interval AccountingRollup_Interval_Field,
accounting_rollup_data_type AccountingRollup_DataType_Field) (
accounting_rollup_put_total AccountingRollup_PutTotal_Field,
accounting_rollup_get_total AccountingRollup_GetTotal_Field,
accounting_rollup_get_audit_total AccountingRollup_GetAuditTotal_Field,
accounting_rollup_get_repair_total AccountingRollup_GetRepairTotal_Field,
accounting_rollup_put_repair_total AccountingRollup_PutRepairTotal_Field,
accounting_rollup_at_rest_total AccountingRollup_AtRestTotal_Field) (
accounting_rollup *AccountingRollup, err error) {
__now := obj.db.Hooks.Now().UTC()
__node_id_val := accounting_rollup_node_id.value()
__start_time_val := accounting_rollup_start_time.value()
__interval_val := accounting_rollup_interval.value()
__data_type_val := accounting_rollup_data_type.value()
__created_at_val := __now
__updated_at_val := __now
__put_total_val := accounting_rollup_put_total.value()
__get_total_val := accounting_rollup_get_total.value()
__get_audit_total_val := accounting_rollup_get_audit_total.value()
__get_repair_total_val := accounting_rollup_get_repair_total.value()
__put_repair_total_val := accounting_rollup_put_repair_total.value()
__at_rest_total_val := accounting_rollup_at_rest_total.value()
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_rollups ( node_id, start_time, interval, data_type, created_at, updated_at ) VALUES ( ?, ?, ?, ?, ?, ? )")
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_rollups ( node_id, start_time, put_total, get_total, get_audit_total, get_repair_total, put_repair_total, at_rest_total ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __node_id_val, __start_time_val, __interval_val, __data_type_val, __created_at_val, __updated_at_val)
obj.logStmt(__stmt, __node_id_val, __start_time_val, __put_total_val, __get_total_val, __get_audit_total_val, __get_repair_total_val, __put_repair_total_val, __at_rest_total_val)
__res, err := obj.driver.Exec(__stmt, __node_id_val, __start_time_val, __interval_val, __data_type_val, __created_at_val, __updated_at_val)
__res, err := obj.driver.Exec(__stmt, __node_id_val, __start_time_val, __put_total_val, __get_total_val, __get_audit_total_val, __get_repair_total_val, __put_repair_total_val, __at_rest_total_val)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3279,14 +3268,13 @@ func (obj *sqlite3Impl) Create_AccountingRaw(ctx context.Context,
__data_total_val := accounting_raw_data_total.value()
__data_type_val := accounting_raw_data_type.value()
__created_at_val := __now
__updated_at_val := __now
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_raws ( node_id, interval_end_time, data_total, data_type, created_at, updated_at ) VALUES ( ?, ?, ?, ?, ?, ? )")
var __embed_stmt = __sqlbundle_Literal("INSERT INTO accounting_raws ( node_id, interval_end_time, data_total, data_type, created_at ) VALUES ( ?, ?, ?, ?, ? )")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val, __updated_at_val)
obj.logStmt(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val)
__res, err := obj.driver.Exec(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val, __updated_at_val)
__res, err := obj.driver.Exec(__stmt, __node_id_val, __interval_end_time_val, __data_total_val, __data_type_val, __created_at_val)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3578,7 +3566,7 @@ func (obj *sqlite3Impl) Get_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field) (
accounting_rollup *AccountingRollup, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE accounting_rollups.id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total FROM accounting_rollups WHERE accounting_rollups.id = ?")
var __values []interface{}
__values = append(__values, accounting_rollup_id.value())
@ -3587,7 +3575,7 @@ func (obj *sqlite3Impl) Get_AccountingRollup_By_Id(ctx context.Context,
obj.logStmt(__stmt, __values...)
accounting_rollup = &AccountingRollup{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3595,14 +3583,14 @@ func (obj *sqlite3Impl) Get_AccountingRollup_By_Id(ctx context.Context,
}
func (obj *sqlite3Impl) All_AccountingRollup_By_NodeId(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field) (
func (obj *sqlite3Impl) All_AccountingRollup_By_StartTime_GreaterOrEqual(ctx context.Context,
accounting_rollup_start_time_greater_or_equal AccountingRollup_StartTime_Field) (
rows []*AccountingRollup, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE accounting_rollups.node_id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total FROM accounting_rollups WHERE accounting_rollups.start_time >= ?")
var __values []interface{}
__values = append(__values, accounting_rollup_node_id.value())
__values = append(__values, accounting_rollup_start_time_greater_or_equal.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
@ -3615,7 +3603,7 @@ func (obj *sqlite3Impl) All_AccountingRollup_By_NodeId(ctx context.Context,
for __rows.Next() {
accounting_rollup := &AccountingRollup{}
err = __rows.Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = __rows.Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3632,7 +3620,7 @@ func (obj *sqlite3Impl) Get_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field) (
accounting_raw *AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE accounting_raws.id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws WHERE accounting_raws.id = ?")
var __values []interface{}
__values = append(__values, accounting_raw_id.value())
@ -3641,7 +3629,7 @@ func (obj *sqlite3Impl) Get_AccountingRaw_By_Id(ctx context.Context,
obj.logStmt(__stmt, __values...)
accounting_raw = &AccountingRaw{}
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = obj.driver.QueryRow(__stmt, __values...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3649,14 +3637,13 @@ func (obj *sqlite3Impl) Get_AccountingRaw_By_Id(ctx context.Context,
}
func (obj *sqlite3Impl) All_AccountingRaw_By_NodeId(ctx context.Context,
accounting_raw_node_id AccountingRaw_NodeId_Field) (
func (obj *sqlite3Impl) All_AccountingRaw(ctx context.Context) (
rows []*AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE accounting_raws.node_id = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws")
var __values []interface{}
__values = append(__values, accounting_raw_node_id.value())
__values = append(__values)
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
@ -3669,7 +3656,40 @@ func (obj *sqlite3Impl) All_AccountingRaw_By_NodeId(ctx context.Context,
for __rows.Next() {
accounting_raw := &AccountingRaw{}
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
rows = append(rows, accounting_raw)
}
if err := __rows.Err(); err != nil {
return nil, obj.makeErr(err)
}
return rows, nil
}
func (obj *sqlite3Impl) All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx context.Context,
accounting_raw_interval_end_time_greater_or_equal AccountingRaw_IntervalEndTime_Field) (
rows []*AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws WHERE accounting_raws.interval_end_time >= ?")
var __values []interface{}
__values = append(__values, accounting_raw_interval_end_time_greater_or_equal.value())
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
__rows, err := obj.driver.Query(__stmt, __values...)
if err != nil {
return nil, obj.makeErr(err)
}
defer __rows.Close()
for __rows.Next() {
accounting_raw := &AccountingRaw{}
err = __rows.Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -3944,98 +3964,6 @@ func (obj *sqlite3Impl) Update_AccountingTimestamps_By_Name(ctx context.Context,
return accounting_timestamps, nil
}
func (obj *sqlite3Impl) Update_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field,
update AccountingRollup_Update_Fields) (
accounting_rollup *AccountingRollup, err error) {
var __sets = &__sqlbundle_Hole{}
var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE accounting_rollups SET "), __sets, __sqlbundle_Literal(" WHERE accounting_rollups.id = ?")}}
__sets_sql := __sqlbundle_Literals{Join: ", "}
var __values []interface{}
var __args []interface{}
__now := obj.db.Hooks.Now().UTC()
__values = append(__values, __now)
__sets_sql.SQLs = append(__sets_sql.SQLs, __sqlbundle_Literal("updated_at = ?"))
__args = append(__args, accounting_rollup_id.value())
__values = append(__values, __args...)
__sets.SQL = __sets_sql
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
accounting_rollup = &AccountingRollup{}
_, err = obj.driver.Exec(__stmt, __values...)
if err != nil {
return nil, obj.makeErr(err)
}
var __embed_stmt_get = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE accounting_rollups.id = ?")
var __stmt_get = __sqlbundle_Render(obj.dialect, __embed_stmt_get)
obj.logStmt("(IMPLIED) "+__stmt_get, __args...)
err = obj.driver.QueryRow(__stmt_get, __args...).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, obj.makeErr(err)
}
return accounting_rollup, nil
}
func (obj *sqlite3Impl) Update_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field,
update AccountingRaw_Update_Fields) (
accounting_raw *AccountingRaw, err error) {
var __sets = &__sqlbundle_Hole{}
var __embed_stmt = __sqlbundle_Literals{Join: "", SQLs: []__sqlbundle_SQL{__sqlbundle_Literal("UPDATE accounting_raws SET "), __sets, __sqlbundle_Literal(" WHERE accounting_raws.id = ?")}}
__sets_sql := __sqlbundle_Literals{Join: ", "}
var __values []interface{}
var __args []interface{}
__now := obj.db.Hooks.Now().UTC()
__values = append(__values, __now)
__sets_sql.SQLs = append(__sets_sql.SQLs, __sqlbundle_Literal("updated_at = ?"))
__args = append(__args, accounting_raw_id.value())
__values = append(__values, __args...)
__sets.SQL = __sets_sql
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, __values...)
accounting_raw = &AccountingRaw{}
_, err = obj.driver.Exec(__stmt, __values...)
if err != nil {
return nil, obj.makeErr(err)
}
var __embed_stmt_get = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE accounting_raws.id = ?")
var __stmt_get = __sqlbundle_Render(obj.dialect, __embed_stmt_get)
obj.logStmt("(IMPLIED) "+__stmt_get, __args...)
err = obj.driver.QueryRow(__stmt_get, __args...).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, obj.makeErr(err)
}
return accounting_raw, nil
}
func (obj *sqlite3Impl) Update_Node_By_Id(ctx context.Context,
node_id Node_Id_Field,
update Node_Update_Fields) (
@ -4488,13 +4416,13 @@ func (obj *sqlite3Impl) getLastAccountingRollup(ctx context.Context,
pk int64) (
accounting_rollup *AccountingRollup, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.interval, accounting_rollups.data_type, accounting_rollups.created_at, accounting_rollups.updated_at FROM accounting_rollups WHERE _rowid_ = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_rollups.id, accounting_rollups.node_id, accounting_rollups.start_time, accounting_rollups.put_total, accounting_rollups.get_total, accounting_rollups.get_audit_total, accounting_rollups.get_repair_total, accounting_rollups.put_repair_total, accounting_rollups.at_rest_total FROM accounting_rollups WHERE _rowid_ = ?")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, pk)
accounting_rollup = &AccountingRollup{}
err = obj.driver.QueryRow(__stmt, pk).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.Interval, &accounting_rollup.DataType, &accounting_rollup.CreatedAt, &accounting_rollup.UpdatedAt)
err = obj.driver.QueryRow(__stmt, pk).Scan(&accounting_rollup.Id, &accounting_rollup.NodeId, &accounting_rollup.StartTime, &accounting_rollup.PutTotal, &accounting_rollup.GetTotal, &accounting_rollup.GetAuditTotal, &accounting_rollup.GetRepairTotal, &accounting_rollup.PutRepairTotal, &accounting_rollup.AtRestTotal)
if err != nil {
return nil, obj.makeErr(err)
}
@ -4506,13 +4434,13 @@ func (obj *sqlite3Impl) getLastAccountingRaw(ctx context.Context,
pk int64) (
accounting_raw *AccountingRaw, err error) {
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at, accounting_raws.updated_at FROM accounting_raws WHERE _rowid_ = ?")
var __embed_stmt = __sqlbundle_Literal("SELECT accounting_raws.id, accounting_raws.node_id, accounting_raws.interval_end_time, accounting_raws.data_total, accounting_raws.data_type, accounting_raws.created_at FROM accounting_raws WHERE _rowid_ = ?")
var __stmt = __sqlbundle_Render(obj.dialect, __embed_stmt)
obj.logStmt(__stmt, pk)
accounting_raw = &AccountingRaw{}
err = obj.driver.QueryRow(__stmt, pk).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt, &accounting_raw.UpdatedAt)
err = obj.driver.QueryRow(__stmt, pk).Scan(&accounting_raw.Id, &accounting_raw.NodeId, &accounting_raw.IntervalEndTime, &accounting_raw.DataTotal, &accounting_raw.DataType, &accounting_raw.CreatedAt)
if err != nil {
return nil, obj.makeErr(err)
}
@ -4719,24 +4647,33 @@ func (rx *Rx) Rollback() (err error) {
return err
}
func (rx *Rx) All_AccountingRaw_By_NodeId(ctx context.Context,
accounting_raw_node_id AccountingRaw_NodeId_Field) (
func (rx *Rx) All_AccountingRaw(ctx context.Context) (
rows []*AccountingRaw, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.All_AccountingRaw_By_NodeId(ctx, accounting_raw_node_id)
return tx.All_AccountingRaw(ctx)
}
func (rx *Rx) All_AccountingRollup_By_NodeId(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field) (
func (rx *Rx) All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx context.Context,
accounting_raw_interval_end_time_greater_or_equal AccountingRaw_IntervalEndTime_Field) (
rows []*AccountingRaw, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx, accounting_raw_interval_end_time_greater_or_equal)
}
func (rx *Rx) All_AccountingRollup_By_StartTime_GreaterOrEqual(ctx context.Context,
accounting_rollup_start_time_greater_or_equal AccountingRollup_StartTime_Field) (
rows []*AccountingRollup, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.All_AccountingRollup_By_NodeId(ctx, accounting_rollup_node_id)
return tx.All_AccountingRollup_By_StartTime_GreaterOrEqual(ctx, accounting_rollup_start_time_greater_or_equal)
}
func (rx *Rx) All_Bwagreement(ctx context.Context) (
@ -4775,14 +4712,18 @@ func (rx *Rx) Create_AccountingRaw(ctx context.Context,
func (rx *Rx) Create_AccountingRollup(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field,
accounting_rollup_start_time AccountingRollup_StartTime_Field,
accounting_rollup_interval AccountingRollup_Interval_Field,
accounting_rollup_data_type AccountingRollup_DataType_Field) (
accounting_rollup_put_total AccountingRollup_PutTotal_Field,
accounting_rollup_get_total AccountingRollup_GetTotal_Field,
accounting_rollup_get_audit_total AccountingRollup_GetAuditTotal_Field,
accounting_rollup_get_repair_total AccountingRollup_GetRepairTotal_Field,
accounting_rollup_put_repair_total AccountingRollup_PutRepairTotal_Field,
accounting_rollup_at_rest_total AccountingRollup_AtRestTotal_Field) (
accounting_rollup *AccountingRollup, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.Create_AccountingRollup(ctx, accounting_rollup_node_id, accounting_rollup_start_time, accounting_rollup_interval, accounting_rollup_data_type)
return tx.Create_AccountingRollup(ctx, accounting_rollup_node_id, accounting_rollup_start_time, accounting_rollup_put_total, accounting_rollup_get_total, accounting_rollup_get_audit_total, accounting_rollup_get_repair_total, accounting_rollup_put_repair_total, accounting_rollup_at_rest_total)
}
@ -5071,28 +5012,6 @@ func (rx *Rx) Limited_OverlayCacheNode_By_NodeId_GreaterOrEqual(ctx context.Cont
return tx.Limited_OverlayCacheNode_By_NodeId_GreaterOrEqual(ctx, overlay_cache_node_node_id_greater_or_equal, limit, offset)
}
func (rx *Rx) Update_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field,
update AccountingRaw_Update_Fields) (
accounting_raw *AccountingRaw, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.Update_AccountingRaw_By_Id(ctx, accounting_raw_id, update)
}
func (rx *Rx) Update_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field,
update AccountingRollup_Update_Fields) (
accounting_rollup *AccountingRollup, err error) {
var tx *Tx
if tx, err = rx.getTx(ctx); err != nil {
return
}
return tx.Update_AccountingRollup_By_Id(ctx, accounting_rollup_id, update)
}
func (rx *Rx) Update_AccountingTimestamps_By_Name(ctx context.Context,
accounting_timestamps_name AccountingTimestamps_Name_Field,
update AccountingTimestamps_Update_Fields) (
@ -5138,12 +5057,15 @@ func (rx *Rx) Update_OverlayCacheNode_By_NodeId(ctx context.Context,
}
type Methods interface {
All_AccountingRaw_By_NodeId(ctx context.Context,
accounting_raw_node_id AccountingRaw_NodeId_Field) (
All_AccountingRaw(ctx context.Context) (
rows []*AccountingRaw, err error)
All_AccountingRollup_By_NodeId(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field) (
All_AccountingRaw_By_IntervalEndTime_GreaterOrEqual(ctx context.Context,
accounting_raw_interval_end_time_greater_or_equal AccountingRaw_IntervalEndTime_Field) (
rows []*AccountingRaw, err error)
All_AccountingRollup_By_StartTime_GreaterOrEqual(ctx context.Context,
accounting_rollup_start_time_greater_or_equal AccountingRollup_StartTime_Field) (
rows []*AccountingRollup, err error)
All_Bwagreement(ctx context.Context) (
@ -5163,8 +5085,12 @@ type Methods interface {
Create_AccountingRollup(ctx context.Context,
accounting_rollup_node_id AccountingRollup_NodeId_Field,
accounting_rollup_start_time AccountingRollup_StartTime_Field,
accounting_rollup_interval AccountingRollup_Interval_Field,
accounting_rollup_data_type AccountingRollup_DataType_Field) (
accounting_rollup_put_total AccountingRollup_PutTotal_Field,
accounting_rollup_get_total AccountingRollup_GetTotal_Field,
accounting_rollup_get_audit_total AccountingRollup_GetAuditTotal_Field,
accounting_rollup_get_repair_total AccountingRollup_GetRepairTotal_Field,
accounting_rollup_put_repair_total AccountingRollup_PutRepairTotal_Field,
accounting_rollup_at_rest_total AccountingRollup_AtRestTotal_Field) (
accounting_rollup *AccountingRollup, err error)
Create_AccountingTimestamps(ctx context.Context,
@ -5295,16 +5221,6 @@ type Methods interface {
limit int, offset int64) (
rows []*OverlayCacheNode, err error)
Update_AccountingRaw_By_Id(ctx context.Context,
accounting_raw_id AccountingRaw_Id_Field,
update AccountingRaw_Update_Fields) (
accounting_raw *AccountingRaw, err error)
Update_AccountingRollup_By_Id(ctx context.Context,
accounting_rollup_id AccountingRollup_Id_Field,
update AccountingRollup_Update_Fields) (
accounting_rollup *AccountingRollup, err error)
Update_AccountingTimestamps_By_Name(ctx context.Context,
accounting_timestamps_name AccountingTimestamps_Name_Field,
update AccountingTimestamps_Update_Fields) (

View File

@ -2,22 +2,23 @@
-- DO NOT EDIT
CREATE TABLE accounting_raws (
id bigserial NOT NULL,
node_id text NOT NULL,
node_id bytea NOT NULL,
interval_end_time timestamp with time zone NOT NULL,
data_total bigint NOT NULL,
data_total double precision NOT NULL,
data_type integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_rollups (
id bigserial NOT NULL,
node_id text NOT NULL,
node_id bytea NOT NULL,
start_time timestamp with time zone NOT NULL,
interval bigint NOT NULL,
data_type integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
put_total bigint NOT NULL,
get_total bigint NOT NULL,
get_audit_total bigint NOT NULL,
get_repair_total bigint NOT NULL,
put_repair_total bigint NOT NULL,
at_rest_total double precision NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_timestamps (

View File

@ -2,22 +2,23 @@
-- DO NOT EDIT
CREATE TABLE accounting_raws (
id INTEGER NOT NULL,
node_id TEXT NOT NULL,
node_id BLOB NOT NULL,
interval_end_time TIMESTAMP NOT NULL,
data_total INTEGER NOT NULL,
data_total REAL NOT NULL,
data_type INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_rollups (
id INTEGER NOT NULL,
node_id TEXT NOT NULL,
node_id BLOB NOT NULL,
start_time TIMESTAMP NOT NULL,
interval INTEGER NOT NULL,
data_type INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL,
put_total INTEGER NOT NULL,
get_total INTEGER NOT NULL,
get_audit_total INTEGER NOT NULL,
get_repair_total INTEGER NOT NULL,
put_repair_total INTEGER NOT NULL,
at_rest_total REAL NOT NULL,
PRIMARY KEY ( id )
);
CREATE TABLE accounting_timestamps (

View File

@ -94,6 +94,27 @@ type lockedAccounting struct {
db accounting.DB
}
// GetRaw retrieves all raw tallies
func (m *lockedAccounting) GetRaw(ctx context.Context) ([]*accounting.Raw, error) {
m.Lock()
defer m.Unlock()
return m.db.GetRaw(ctx)
}
// GetRawSince r retrieves all raw tallies sinces
func (m *lockedAccounting) GetRawSince(ctx context.Context, latestRollup time.Time) ([]*accounting.Raw, error) {
m.Lock()
defer m.Unlock()
return m.db.GetRawSince(ctx, latestRollup)
}
// SaveRollup records raw tallies of at rest data to the database
func (m *lockedAccounting) SaveRollup(ctx context.Context, latestTally time.Time, stats accounting.RollupStats) error {
m.Lock()
defer m.Unlock()
return m.db.SaveRollup(ctx, latestTally, stats)
}
// LastRawTime records the latest last tallied time.
func (m *lockedAccounting) LastRawTime(ctx context.Context, timestampType string) (time.Time, bool, error) {
m.Lock()
@ -102,7 +123,7 @@ func (m *lockedAccounting) LastRawTime(ctx context.Context, timestampType string
}
// SaveAtRestRaw records raw tallies of at-rest-data.
func (m *lockedAccounting) SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]int64) error {
func (m *lockedAccounting) SaveAtRestRaw(ctx context.Context, latestTally time.Time, nodeData map[storj.NodeID]float64) error {
m.Lock()
defer m.Unlock()
return m.db.SaveAtRestRaw(ctx, latestTally, nodeData)