summaryrefslogtreecommitdiff
path: root/db/query.sql.go
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-07-07 08:32:11 +0530
committersinanmohd <sinan@sinanmohd.com>2024-07-07 08:32:11 +0530
commit87b230e71a830e191dd5c14aa94a025c39792145 (patch)
treee85c8fc6154f9f1f9d7aef3045fd31f61a9498ee /db/query.sql.go
parenta1692f732078adad272256639f7a3ff14c9e643a (diff)
api/usage: init
Diffstat (limited to 'db/query.sql.go')
-rw-r--r--db/query.sql.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/db/query.sql.go b/db/query.sql.go
index 7afe159..d6304a7 100644
--- a/db/query.sql.go
+++ b/db/query.sql.go
@@ -37,3 +37,19 @@ func (q *Queries) EnterUsage(ctx context.Context, arg EnterUsageParams) error {
)
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
+}