summaryrefslogblamecommitdiff
path: root/db/query.sql.go
blob: d6304a73283a0ef9d197b80551b9a7210d3d2b5a (plain) (tree)





















                                                    
                          

                                     

                          











                                                                               















                                                                      
// Code generated by sqlc. DO NOT EDIT.
// versions:
//   sqlc v1.26.0
// source: query.sql

package db

import (
	"context"

	"github.com/jackc/pgx/v5/pgtype"
)

const enterUsage = `-- name: EnterUsage :exec
INSERT INTO Usage (
  HardwareAddr, StartTime, StopTime, Egress, Ingress
) VALUES (
  $1, $2, $3, $4, $5
)
`

type EnterUsageParams struct {
	Hardwareaddr int64
	Starttime    pgtype.Timestamp
	Stoptime     pgtype.Timestamp
	Egress       int64
	Ingress      int64
}

func (q *Queries) EnterUsage(ctx context.Context, arg EnterUsageParams) error {
	_, err := q.db.Exec(ctx, enterUsage,
		arg.Hardwareaddr,
		arg.Starttime,
		arg.Stoptime,
		arg.Egress,
		arg.Ingress,
	)
	return err
}

const getUsage = `-- name: GetUsage :one
SELECT SUM(Ingress) AS Ingress, SUM(Egress) AS Egress FROM Usage
`

type GetUsageRow struct {
	Ingress int64
	Egress  int64
}

func (q *Queries) GetUsage(ctx context.Context) (GetUsageRow, error) {
	row := q.db.QueryRow(ctx, getUsage)
	var i GetUsageRow
	err := row.Scan(&i.Ingress, &i.Egress)
	return i, err
}