Add trap count data to source page
It's...way too many rows, now that I have the actual data. It needs to be reworked.
This commit is contained in:
parent
26ee3efcc8
commit
e7ece52c8c
32 changed files with 1622 additions and 298 deletions
114
sql/trapcount_by_location_id.bob.go
Normal file
114
sql/trapcount_by_location_id.bob.go
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
// 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/aarondl/opt/null"
|
||||
"github.com/shopspring/decimal"
|
||||
"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 trapcount_by_location_id.bob.sql
|
||||
var formattedQueries_trapcount_by_location_id string
|
||||
|
||||
var trapCountByLocationIDSQL = formattedQueries_trapcount_by_location_id[159:580]
|
||||
|
||||
type TrapCountByLocationIDQuery = orm.ModQuery[*dialect.SelectQuery, trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]
|
||||
|
||||
func TrapCountByLocationID(OrganizationID int32, LocID []string) *TrapCountByLocationIDQuery {
|
||||
var expressionTypArgs trapCountByLocationID
|
||||
|
||||
expressionTypArgs.OrganizationID = psql.Arg(OrganizationID)
|
||||
expressionTypArgs.LocID = expr.ToArgs(LocID...)
|
||||
|
||||
return &TrapCountByLocationIDQuery{
|
||||
Query: orm.Query[trapCountByLocationID, TrapCountByLocationIDRow, []TrapCountByLocationIDRow, trapCountByLocationIDTransformer]{
|
||||
ExecQuery: orm.ExecQuery[trapCountByLocationID]{
|
||||
BaseQuery: bob.BaseQuery[trapCountByLocationID]{
|
||||
Expression: expressionTypArgs,
|
||||
Dialect: dialect.Dialect,
|
||||
QueryType: bob.QueryTypeSelect,
|
||||
},
|
||||
},
|
||||
Scanner: func(context.Context, []string) (func(*scan.Row) (any, error), func(any) (TrapCountByLocationIDRow, error)) {
|
||||
return func(row *scan.Row) (any, error) {
|
||||
var t TrapCountByLocationIDRow
|
||||
row.ScheduleScanByIndex(0, &t.TrapdataGlobalid)
|
||||
row.ScheduleScanByIndex(1, &t.TrapdataEnddate)
|
||||
row.ScheduleScanByIndex(2, &t.TotalFemales)
|
||||
row.ScheduleScanByIndex(3, &t.TotalMales)
|
||||
row.ScheduleScanByIndex(4, &t.Total)
|
||||
return &t, nil
|
||||
}, func(v any) (TrapCountByLocationIDRow, error) {
|
||||
return *(v.(*TrapCountByLocationIDRow)), nil
|
||||
}
|
||||
},
|
||||
},
|
||||
Mod: bob.ModFunc[*dialect.SelectQuery](func(q *dialect.SelectQuery) {
|
||||
q.AppendSelect(expressionTypArgs.subExpr(12, 223))
|
||||
q.SetTable(expressionTypArgs.subExpr(234, 318))
|
||||
q.AppendWhere(expressionTypArgs.subExpr(330, 379))
|
||||
q.AppendGroup(expressionTypArgs.subExpr(394, 421))
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TrapCountByLocationIDRow = struct {
|
||||
TrapdataGlobalid string `db:"trapdata_globalid"`
|
||||
TrapdataEnddate null.Val[int64] `db:"trapdata_enddate"`
|
||||
TotalFemales decimal.Decimal `db:"total_females"`
|
||||
TotalMales int64 `db:"total_males"`
|
||||
Total decimal.Decimal `db:"total"`
|
||||
}
|
||||
|
||||
type trapCountByLocationIDTransformer = bob.SliceTransformer[TrapCountByLocationIDRow, []TrapCountByLocationIDRow]
|
||||
|
||||
type trapCountByLocationID struct {
|
||||
OrganizationID bob.Expression
|
||||
LocID bob.Expression
|
||||
}
|
||||
|
||||
func (o trapCountByLocationID) args() iter.Seq[orm.ArgWithPosition] {
|
||||
return func(yield func(arg orm.ArgWithPosition) bool) {
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "organizationID",
|
||||
Start: 351,
|
||||
Stop: 353,
|
||||
Expression: o.OrganizationID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
|
||||
if !yield(orm.ArgWithPosition{
|
||||
Name: "locID",
|
||||
Start: 376,
|
||||
Stop: 378,
|
||||
Expression: o.LocID,
|
||||
}) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (o trapCountByLocationID) raw(from, to int) string {
|
||||
return trapCountByLocationIDSQL[from:to]
|
||||
}
|
||||
|
||||
func (o trapCountByLocationID) subExpr(from, to int) bob.Expression {
|
||||
return orm.ArgsToExpression(trapCountByLocationIDSQL, from, to, o.args())
|
||||
}
|
||||
|
||||
func (o trapCountByLocationID) WriteSQL(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
|
||||
return o.subExpr(0, len(trapCountByLocationIDSQL)).WriteSQL(ctx, w, d, start)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue