nidus-sync/sql/trapdata_by_location_id_recent.bob.go
Eli Ribble b7318ae973
Only get the latest 10 trap collections
Otherwise the page gets really swamped
2025-11-21 16:28:03 +00:00

108 lines
3.6 KiB
Go

// Code generated by BobGen psql v0.41.1. DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package sql
import (
"context"
_ "embed"
"io"
"iter"
"github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/dialect"
"github.com/stephenafamo/bob/expr"
"github.com/stephenafamo/bob/orm"
"github.com/stephenafamo/scan"
)
//go:embed trapdata_by_location_id_recent.bob.sql
var formattedQueries_trapdata_by_location_id_recent string
var trapDataByLocationIDRecentSQL = formattedQueries_trapdata_by_location_id_recent[164:454]
type TrapDataByLocationIDRecentQuery = orm.ModQuery[*dialect.SelectQuery, trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer]
func TrapDataByLocationIDRecent(OrganizationID int32, LocID []string) *TrapDataByLocationIDRecentQuery {
var expressionTypArgs trapDataByLocationIDRecent
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
expressionTypArgs.LocID = expr.ToArgs(LocID...)
return &TrapDataByLocationIDRecentQuery{
Query: orm.Query[trapDataByLocationIDRecent, TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow, trapDataByLocationIDRecentTransformer]{
ExecQuery: orm.ExecQuery[trapDataByLocationIDRecent]{
BaseQuery: bob.BaseQuery[trapDataByLocationIDRecent]{
Expression: expressionTypArgs,
Dialect: dialect.Dialect,
QueryType: bob.QueryTypeSelect,
},
},
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (TrapDataByLocationIDRecentRow, error)) {
return func(row *scan.Row) (any, error) {
var t TrapDataByLocationIDRecentRow
row.ScheduleScanByIndex(0, &t.Enddatetime)
row.ScheduleScanByIndex(1, &t.Globalid)
row.ScheduleScanByIndex(2, &t.LocID)
return &t, nil
}, func(v any) (TrapDataByLocationIDRecentRow, error) {
return *(v.(*TrapDataByLocationIDRecentRow)), nil
}
},
},
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
q.AppendSelect(expressionTypArgs.subExpr(7, 36))
q.SetTable(expressionTypArgs.subExpr(42, 244))
q.AppendWhere(expressionTypArgs.subExpr(251, 264))
q.CombinedOrder.AppendOrder(expressionTypArgs.subExpr(274, 290))
}),
}
}
type TrapDataByLocationIDRecentRow = struct {
Enddatetime int64 `db:"enddatetime"`
Globalid string `db:"globalid"`
LocID string `db:"loc_id"`
}
type trapDataByLocationIDRecentTransformer = bob.SliceTransformer[TrapDataByLocationIDRecentRow, []TrapDataByLocationIDRecentRow]
type trapDataByLocationIDRecent struct {
OrganizationID bob.Expression
LocID bob.Expression
}
func (o trapDataByLocationIDRecent) args() iter.Seq[orm.ArgWithPosition] {
return func(yield func(arg orm.ArgWithPosition) bool) {
if !yield(orm.ArgWithPosition{
Name: "organizationID",
Start: 207,
Stop: 209,
Expression: o.OrganizationID,
}) {
return
}
if !yield(orm.ArgWithPosition{
Name: "locID",
Start: 227,
Stop: 229,
Expression: o.LocID,
}) {
return
}
}
}
func (o trapDataByLocationIDRecent) raw(from, to int) string {
return trapDataByLocationIDRecentSQL[from:to]
}
func (o trapDataByLocationIDRecent) subExpr(from, to int) bob.Expression {
return orm.ArgsToExpression(trapDataByLocationIDRecentSQL, from, to, o.args())
}
func (o trapDataByLocationIDRecent) WriteSQL(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
return o.subExpr(0, len(trapDataByLocationIDRecentSQL)).WriteSQL(ctx, w, d, start)
}