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:
Eli Ribble 2025-11-20 20:59:28 +00:00
parent 26ee3efcc8
commit e7ece52c8c
No known key found for this signature in database
32 changed files with 1622 additions and 298 deletions

View file

@ -87,6 +87,7 @@ type FSMosquitoinspection struct {
Adminaction null.Val[string] `db:"adminaction" `
Ptaid null.Val[string] `db:"ptaid" `
Updated time.Time `db:"updated" `
Geom null.Val[string] `db:"geom" `
R fsMosquitoinspectionR `db:"-" `
}
@ -109,7 +110,7 @@ type fsMosquitoinspectionR struct {
func buildFSMosquitoinspectionColumns(alias string) fsMosquitoinspectionColumns {
return fsMosquitoinspectionColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "actiontaken", "activity", "adultact", "avetemp", "avglarvae", "avgpupae", "breeding", "cbcount", "comments", "containercount", "creationdate", "creator", "domstage", "eggs", "enddatetime", "editdate", "editor", "fieldspecies", "fieldtech", "globalid", "jurisdiction", "larvaepresent", "linelocid", "locationname", "lstages", "numdips", "objectid", "personalcontact", "pointlocid", "polygonlocid", "posdips", "positivecontainercount", "pupaepresent", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "tirecount", "totlarvae", "totpupae", "visualmonitoring", "vmcomments", "winddir", "windspeed", "zone", "zone2", "created_date", "created_user", "geometry_x", "geometry_y", "last_edited_date", "last_edited_user", "adminaction", "ptaid", "updated",
"organization_id", "actiontaken", "activity", "adultact", "avetemp", "avglarvae", "avgpupae", "breeding", "cbcount", "comments", "containercount", "creationdate", "creator", "domstage", "eggs", "enddatetime", "editdate", "editor", "fieldspecies", "fieldtech", "globalid", "jurisdiction", "larvaepresent", "linelocid", "locationname", "lstages", "numdips", "objectid", "personalcontact", "pointlocid", "polygonlocid", "posdips", "positivecontainercount", "pupaepresent", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "tirecount", "totlarvae", "totpupae", "visualmonitoring", "vmcomments", "winddir", "windspeed", "zone", "zone2", "created_date", "created_user", "geometry_x", "geometry_y", "last_edited_date", "last_edited_user", "adminaction", "ptaid", "updated", "geom",
).WithParent("fs_mosquitoinspection"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -173,6 +174,7 @@ func buildFSMosquitoinspectionColumns(alias string) fsMosquitoinspectionColumns
Adminaction: psql.Quote(alias, "adminaction"),
Ptaid: psql.Quote(alias, "ptaid"),
Updated: psql.Quote(alias, "updated"),
Geom: psql.Quote(alias, "geom"),
}
}
@ -240,6 +242,7 @@ type fsMosquitoinspectionColumns struct {
Adminaction psql.Expression
Ptaid psql.Expression
Updated psql.Expression
Geom psql.Expression
}
func (c fsMosquitoinspectionColumns) Alias() string {
@ -315,10 +318,11 @@ type FSMosquitoinspectionSetter struct {
Adminaction omitnull.Val[string] `db:"adminaction" `
Ptaid omitnull.Val[string] `db:"ptaid" `
Updated omit.Val[time.Time] `db:"updated" `
Geom omitnull.Val[string] `db:"geom" `
}
func (s FSMosquitoinspectionSetter) SetColumns() []string {
vals := make([]string, 0, 61)
vals := make([]string, 0, 62)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -502,6 +506,9 @@ func (s FSMosquitoinspectionSetter) SetColumns() []string {
if s.Updated.IsValue() {
vals = append(vals, "updated")
}
if !s.Geom.IsUnset() {
vals = append(vals, "geom")
}
return vals
}
@ -689,6 +696,9 @@ func (s FSMosquitoinspectionSetter) Overwrite(t *FSMosquitoinspection) {
if s.Updated.IsValue() {
t.Updated = s.Updated.MustGet()
}
if !s.Geom.IsUnset() {
t.Geom = s.Geom.MustGetNull()
}
}
func (s *FSMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) {
@ -697,7 +707,7 @@ func (s *FSMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 61)
vals := make([]bob.Expression, 62)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -1064,6 +1074,12 @@ func (s *FSMosquitoinspectionSetter) Apply(q *dialect.InsertQuery) {
vals[60] = psql.Raw("DEFAULT")
}
if !s.Geom.IsUnset() {
vals[61] = psql.Arg(s.Geom.MustGetNull())
} else {
vals[61] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -1073,7 +1089,7 @@ func (s FSMosquitoinspectionSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s FSMosquitoinspectionSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 61)
exprs := make([]bob.Expression, 0, 62)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1502,6 +1518,13 @@ func (s FSMosquitoinspectionSetter) Expressions(prefix ...string) []bob.Expressi
}})
}
if !s.Geom.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geom")...),
psql.Arg(s.Geom),
}})
}
return exprs
}
@ -1862,6 +1885,7 @@ type fsMosquitoinspectionWhere[Q psql.Filterable] struct {
Adminaction psql.WhereNullMod[Q, string]
Ptaid psql.WhereNullMod[Q, string]
Updated psql.WhereMod[Q, time.Time]
Geom psql.WhereNullMod[Q, string]
}
func (fsMosquitoinspectionWhere[Q]) AliasedAs(alias string) fsMosquitoinspectionWhere[Q] {
@ -1931,6 +1955,7 @@ func buildFSMosquitoinspectionWhere[Q psql.Filterable](cols fsMosquitoinspection
Adminaction: psql.WhereNull[Q, string](cols.Adminaction),
Ptaid: psql.WhereNull[Q, string](cols.Ptaid),
Updated: psql.Where[Q, time.Time](cols.Updated),
Geom: psql.WhereNull[Q, string](cols.Geom),
}
}

View file

@ -74,6 +74,7 @@ type FSPointlocation struct {
Scalarpriority null.Val[int64] `db:"scalarpriority" `
Sourcestatus null.Val[string] `db:"sourcestatus" `
Updated time.Time `db:"updated" `
Geom null.Val[string] `db:"geom" `
R fsPointlocationR `db:"-" `
}
@ -96,7 +97,7 @@ type fsPointlocationR struct {
func buildFSPointlocationColumns(alias string) fsPointlocationColumns {
return fsPointlocationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "accessdesc", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "globalid", "habitat", "jurisdiction", "larvinspectinterval", "lastinspectactiontaken", "lastinspectactivity", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectbreeding", "lastinspectconditions", "lastinspectdate", "lastinspectfieldspecies", "lastinspectlstages", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "stype", "symbology", "usetype", "waterorigin", "x", "y", "zone", "zone2", "geometry_x", "geometry_y", "assignedtech", "deactivate_reason", "scalarpriority", "sourcestatus", "updated",
"organization_id", "accessdesc", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "globalid", "habitat", "jurisdiction", "larvinspectinterval", "lastinspectactiontaken", "lastinspectactivity", "lastinspectavglarvae", "lastinspectavgpupae", "lastinspectbreeding", "lastinspectconditions", "lastinspectdate", "lastinspectfieldspecies", "lastinspectlstages", "lasttreatactivity", "lasttreatdate", "lasttreatproduct", "lasttreatqty", "lasttreatqtyunit", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "stype", "symbology", "usetype", "waterorigin", "x", "y", "zone", "zone2", "geometry_x", "geometry_y", "assignedtech", "deactivate_reason", "scalarpriority", "sourcestatus", "updated", "geom",
).WithParent("fs_pointlocation"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -147,6 +148,7 @@ func buildFSPointlocationColumns(alias string) fsPointlocationColumns {
Scalarpriority: psql.Quote(alias, "scalarpriority"),
Sourcestatus: psql.Quote(alias, "sourcestatus"),
Updated: psql.Quote(alias, "updated"),
Geom: psql.Quote(alias, "geom"),
}
}
@ -201,6 +203,7 @@ type fsPointlocationColumns struct {
Scalarpriority psql.Expression
Sourcestatus psql.Expression
Updated psql.Expression
Geom psql.Expression
}
func (c fsPointlocationColumns) Alias() string {
@ -263,10 +266,11 @@ type FSPointlocationSetter struct {
Scalarpriority omitnull.Val[int64] `db:"scalarpriority" `
Sourcestatus omitnull.Val[string] `db:"sourcestatus" `
Updated omit.Val[time.Time] `db:"updated" `
Geom omitnull.Val[string] `db:"geom" `
}
func (s FSPointlocationSetter) SetColumns() []string {
vals := make([]string, 0, 48)
vals := make([]string, 0, 49)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -411,6 +415,9 @@ func (s FSPointlocationSetter) SetColumns() []string {
if s.Updated.IsValue() {
vals = append(vals, "updated")
}
if !s.Geom.IsUnset() {
vals = append(vals, "geom")
}
return vals
}
@ -559,6 +566,9 @@ func (s FSPointlocationSetter) Overwrite(t *FSPointlocation) {
if s.Updated.IsValue() {
t.Updated = s.Updated.MustGet()
}
if !s.Geom.IsUnset() {
t.Geom = s.Geom.MustGetNull()
}
}
func (s *FSPointlocationSetter) Apply(q *dialect.InsertQuery) {
@ -567,7 +577,7 @@ func (s *FSPointlocationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 48)
vals := make([]bob.Expression, 49)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -856,6 +866,12 @@ func (s *FSPointlocationSetter) Apply(q *dialect.InsertQuery) {
vals[47] = psql.Raw("DEFAULT")
}
if !s.Geom.IsUnset() {
vals[48] = psql.Arg(s.Geom.MustGetNull())
} else {
vals[48] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -865,7 +881,7 @@ func (s FSPointlocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s FSPointlocationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 48)
exprs := make([]bob.Expression, 0, 49)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1203,6 +1219,13 @@ func (s FSPointlocationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.Geom.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geom")...),
psql.Arg(s.Geom),
}})
}
return exprs
}
@ -1550,6 +1573,7 @@ type fsPointlocationWhere[Q psql.Filterable] struct {
Scalarpriority psql.WhereNullMod[Q, int64]
Sourcestatus psql.WhereNullMod[Q, string]
Updated psql.WhereMod[Q, time.Time]
Geom psql.WhereNullMod[Q, string]
}
func (fsPointlocationWhere[Q]) AliasedAs(alias string) fsPointlocationWhere[Q] {
@ -1606,6 +1630,7 @@ func buildFSPointlocationWhere[Q psql.Filterable](cols fsPointlocationColumns) f
Scalarpriority: psql.WhereNull[Q, int64](cols.Scalarpriority),
Sourcestatus: psql.WhereNull[Q, string](cols.Sourcestatus),
Updated: psql.Where[Q, time.Time](cols.Updated),
Geom: psql.WhereNull[Q, string](cols.Geom),
}
}

View file

@ -60,6 +60,7 @@ type FSTraplocation struct {
H3R7 null.Val[string] `db:"h3r7" `
H3R8 null.Val[string] `db:"h3r8" `
Updated time.Time `db:"updated" `
Geom null.Val[string] `db:"geom" `
R fsTraplocationR `db:"-" `
}
@ -82,7 +83,7 @@ type fsTraplocationR struct {
func buildFSTraplocationColumns(alias string) fsTraplocationColumns {
return fsTraplocationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "accessdesc", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "gatewaysync", "globalid", "habitat", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "usetype", "zone", "zone2", "created_date", "created_user", "geometry_x", "geometry_y", "last_edited_date", "last_edited_user", "route", "route_order", "set_dow", "vectorsurvsiteid", "h3r7", "h3r8", "updated",
"organization_id", "accessdesc", "active", "comments", "creationdate", "creator", "description", "externalid", "editdate", "editor", "gatewaysync", "globalid", "habitat", "locationnumber", "name", "nextactiondatescheduled", "objectid", "priority", "usetype", "zone", "zone2", "created_date", "created_user", "geometry_x", "geometry_y", "last_edited_date", "last_edited_user", "route", "route_order", "set_dow", "vectorsurvsiteid", "h3r7", "h3r8", "updated", "geom",
).WithParent("fs_traplocation"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -119,6 +120,7 @@ func buildFSTraplocationColumns(alias string) fsTraplocationColumns {
H3R7: psql.Quote(alias, "h3r7"),
H3R8: psql.Quote(alias, "h3r8"),
Updated: psql.Quote(alias, "updated"),
Geom: psql.Quote(alias, "geom"),
}
}
@ -159,6 +161,7 @@ type fsTraplocationColumns struct {
H3R7 psql.Expression
H3R8 psql.Expression
Updated psql.Expression
Geom psql.Expression
}
func (c fsTraplocationColumns) Alias() string {
@ -207,10 +210,11 @@ type FSTraplocationSetter struct {
H3R7 omitnull.Val[string] `db:"h3r7" `
H3R8 omitnull.Val[string] `db:"h3r8" `
Updated omit.Val[time.Time] `db:"updated" `
Geom omitnull.Val[string] `db:"geom" `
}
func (s FSTraplocationSetter) SetColumns() []string {
vals := make([]string, 0, 34)
vals := make([]string, 0, 35)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -313,6 +317,9 @@ func (s FSTraplocationSetter) SetColumns() []string {
if s.Updated.IsValue() {
vals = append(vals, "updated")
}
if !s.Geom.IsUnset() {
vals = append(vals, "geom")
}
return vals
}
@ -419,6 +426,9 @@ func (s FSTraplocationSetter) Overwrite(t *FSTraplocation) {
if s.Updated.IsValue() {
t.Updated = s.Updated.MustGet()
}
if !s.Geom.IsUnset() {
t.Geom = s.Geom.MustGetNull()
}
}
func (s *FSTraplocationSetter) Apply(q *dialect.InsertQuery) {
@ -427,7 +437,7 @@ func (s *FSTraplocationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 34)
vals := make([]bob.Expression, 35)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -632,6 +642,12 @@ func (s *FSTraplocationSetter) Apply(q *dialect.InsertQuery) {
vals[33] = psql.Raw("DEFAULT")
}
if !s.Geom.IsUnset() {
vals[34] = psql.Arg(s.Geom.MustGetNull())
} else {
vals[34] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -641,7 +657,7 @@ func (s FSTraplocationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s FSTraplocationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 34)
exprs := make([]bob.Expression, 0, 35)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -881,6 +897,13 @@ func (s FSTraplocationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.Geom.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geom")...),
psql.Arg(s.Geom),
}})
}
return exprs
}
@ -1214,6 +1237,7 @@ type fsTraplocationWhere[Q psql.Filterable] struct {
H3R7 psql.WhereNullMod[Q, string]
H3R8 psql.WhereNullMod[Q, string]
Updated psql.WhereMod[Q, time.Time]
Geom psql.WhereNullMod[Q, string]
}
func (fsTraplocationWhere[Q]) AliasedAs(alias string) fsTraplocationWhere[Q] {
@ -1256,6 +1280,7 @@ func buildFSTraplocationWhere[Q psql.Filterable](cols fsTraplocationColumns) fsT
H3R7: psql.WhereNull[Q, string](cols.H3R7),
H3R8: psql.WhereNull[Q, string](cols.H3R8),
Updated: psql.Where[Q, time.Time](cols.Updated),
Geom: psql.WhereNull[Q, string](cols.Geom),
}
}

View file

@ -84,6 +84,7 @@ type FSTreatment struct {
GeometryY null.Val[float64] `db:"geometry_y" `
TempSitecond null.Val[string] `db:"temp_sitecond" `
Updated time.Time `db:"updated" `
Geom null.Val[string] `db:"geom" `
R fsTreatmentR `db:"-" `
}
@ -106,7 +107,7 @@ type fsTreatmentR struct {
func buildFSTreatmentColumns(alias string) fsTreatmentColumns {
return fsTreatmentColumns{
ColumnsExpr: expr.NewColumnsExpr(
"organization_id", "activity", "areaunit", "avetemp", "barrierrouteid", "cbcount", "comments", "containercount", "creationdate", "creator", "enddatetime", "equiptype", "editdate", "editor", "fieldtech", "flowrate", "globalid", "habitat", "insp_id", "invloc", "linelocid", "locationname", "method", "objectid", "pointlocid", "polygonlocid", "product", "ptaid", "qty", "qtyunit", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "targetspecies", "tirecount", "treatacres", "treatarea", "treathectares", "treatmenthours", "treatmentlength", "treatmentlengthunits", "totalcostprodcut", "ulvrouteid", "warningoverride", "winddir", "windspeed", "zone", "zone2", "geometry_x", "geometry_y", "temp_sitecond", "updated",
"organization_id", "activity", "areaunit", "avetemp", "barrierrouteid", "cbcount", "comments", "containercount", "creationdate", "creator", "enddatetime", "equiptype", "editdate", "editor", "fieldtech", "flowrate", "globalid", "habitat", "insp_id", "invloc", "linelocid", "locationname", "method", "objectid", "pointlocid", "polygonlocid", "product", "ptaid", "qty", "qtyunit", "raingauge", "recordstatus", "reviewed", "reviewedby", "revieweddate", "sdid", "sitecond", "srid", "startdatetime", "targetspecies", "tirecount", "treatacres", "treatarea", "treathectares", "treatmenthours", "treatmentlength", "treatmentlengthunits", "totalcostprodcut", "ulvrouteid", "warningoverride", "winddir", "windspeed", "zone", "zone2", "geometry_x", "geometry_y", "temp_sitecond", "updated", "geom",
).WithParent("fs_treatment"),
tableAlias: alias,
OrganizationID: psql.Quote(alias, "organization_id"),
@ -167,6 +168,7 @@ func buildFSTreatmentColumns(alias string) fsTreatmentColumns {
GeometryY: psql.Quote(alias, "geometry_y"),
TempSitecond: psql.Quote(alias, "temp_sitecond"),
Updated: psql.Quote(alias, "updated"),
Geom: psql.Quote(alias, "geom"),
}
}
@ -231,6 +233,7 @@ type fsTreatmentColumns struct {
GeometryY psql.Expression
TempSitecond psql.Expression
Updated psql.Expression
Geom psql.Expression
}
func (c fsTreatmentColumns) Alias() string {
@ -303,10 +306,11 @@ type FSTreatmentSetter struct {
GeometryY omitnull.Val[float64] `db:"geometry_y" `
TempSitecond omitnull.Val[string] `db:"temp_sitecond" `
Updated omit.Val[time.Time] `db:"updated" `
Geom omitnull.Val[string] `db:"geom" `
}
func (s FSTreatmentSetter) SetColumns() []string {
vals := make([]string, 0, 58)
vals := make([]string, 0, 59)
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
@ -481,6 +485,9 @@ func (s FSTreatmentSetter) SetColumns() []string {
if s.Updated.IsValue() {
vals = append(vals, "updated")
}
if !s.Geom.IsUnset() {
vals = append(vals, "geom")
}
return vals
}
@ -659,6 +666,9 @@ func (s FSTreatmentSetter) Overwrite(t *FSTreatment) {
if s.Updated.IsValue() {
t.Updated = s.Updated.MustGet()
}
if !s.Geom.IsUnset() {
t.Geom = s.Geom.MustGetNull()
}
}
func (s *FSTreatmentSetter) Apply(q *dialect.InsertQuery) {
@ -667,7 +677,7 @@ func (s *FSTreatmentSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 58)
vals := make([]bob.Expression, 59)
if s.OrganizationID.IsValue() {
vals[0] = psql.Arg(s.OrganizationID.MustGet())
} else {
@ -1016,6 +1026,12 @@ func (s *FSTreatmentSetter) Apply(q *dialect.InsertQuery) {
vals[57] = psql.Raw("DEFAULT")
}
if !s.Geom.IsUnset() {
vals[58] = psql.Arg(s.Geom.MustGetNull())
} else {
vals[58] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -1025,7 +1041,7 @@ func (s FSTreatmentSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s FSTreatmentSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 58)
exprs := make([]bob.Expression, 0, 59)
if s.OrganizationID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -1433,6 +1449,13 @@ func (s FSTreatmentSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.Geom.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "geom")...),
psql.Arg(s.Geom),
}})
}
return exprs
}
@ -1790,6 +1813,7 @@ type fsTreatmentWhere[Q psql.Filterable] struct {
GeometryY psql.WhereNullMod[Q, float64]
TempSitecond psql.WhereNullMod[Q, string]
Updated psql.WhereMod[Q, time.Time]
Geom psql.WhereNullMod[Q, string]
}
func (fsTreatmentWhere[Q]) AliasedAs(alias string) fsTreatmentWhere[Q] {
@ -1856,6 +1880,7 @@ func buildFSTreatmentWhere[Q psql.Filterable](cols fsTreatmentColumns) fsTreatme
GeometryY: psql.WhereNull[Q, float64](cols.GeometryY),
TempSitecond: psql.WhereNull[Q, string](cols.TempSitecond),
Updated: psql.Where[Q, time.Time](cols.Updated),
Geom: psql.WhereNull[Q, string](cols.Geom),
}
}

View file

@ -9,7 +9,9 @@ import (
"io"
enums "github.com/Gleipnir-Technology/nidus-sync/enums"
"github.com/aarondl/opt/null"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/stephenafamo/bob"
"github.com/stephenafamo/bob/dialect/psql"
"github.com/stephenafamo/bob/dialect/psql/dialect"
@ -26,10 +28,11 @@ import (
type H3Aggregation struct {
ID int32 `db:"id,pk" `
Cell string `db:"cell" `
Resolution int32 `db:"resolution" `
Count int32 `db:"count_" `
Type enums.H3aggregationtype `db:"type_" `
Geometry null.Val[string] `db:"geometry" `
OrganizationID int32 `db:"organization_id" `
Resolution int32 `db:"resolution" `
Type enums.H3aggregationtype `db:"type_" `
R h3AggregationR `db:"-" `
}
@ -52,15 +55,16 @@ type h3AggregationR struct {
func buildH3AggregationColumns(alias string) h3AggregationColumns {
return h3AggregationColumns{
ColumnsExpr: expr.NewColumnsExpr(
"id", "cell", "resolution", "count_", "type_", "organization_id",
"id", "cell", "count_", "geometry", "organization_id", "resolution", "type_",
).WithParent("h3_aggregation"),
tableAlias: alias,
ID: psql.Quote(alias, "id"),
Cell: psql.Quote(alias, "cell"),
Resolution: psql.Quote(alias, "resolution"),
Count: psql.Quote(alias, "count_"),
Type: psql.Quote(alias, "type_"),
Geometry: psql.Quote(alias, "geometry"),
OrganizationID: psql.Quote(alias, "organization_id"),
Resolution: psql.Quote(alias, "resolution"),
Type: psql.Quote(alias, "type_"),
}
}
@ -69,10 +73,11 @@ type h3AggregationColumns struct {
tableAlias string
ID psql.Expression
Cell psql.Expression
Resolution psql.Expression
Count psql.Expression
Type psql.Expression
Geometry psql.Expression
OrganizationID psql.Expression
Resolution psql.Expression
Type psql.Expression
}
func (c h3AggregationColumns) Alias() string {
@ -89,32 +94,36 @@ func (h3AggregationColumns) AliasedAs(alias string) h3AggregationColumns {
type H3AggregationSetter struct {
ID omit.Val[int32] `db:"id,pk" `
Cell omit.Val[string] `db:"cell" `
Resolution omit.Val[int32] `db:"resolution" `
Count omit.Val[int32] `db:"count_" `
Type omit.Val[enums.H3aggregationtype] `db:"type_" `
Geometry omitnull.Val[string] `db:"geometry" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Resolution omit.Val[int32] `db:"resolution" `
Type omit.Val[enums.H3aggregationtype] `db:"type_" `
}
func (s H3AggregationSetter) SetColumns() []string {
vals := make([]string, 0, 6)
vals := make([]string, 0, 7)
if s.ID.IsValue() {
vals = append(vals, "id")
}
if s.Cell.IsValue() {
vals = append(vals, "cell")
}
if s.Resolution.IsValue() {
vals = append(vals, "resolution")
}
if s.Count.IsValue() {
vals = append(vals, "count_")
}
if s.Type.IsValue() {
vals = append(vals, "type_")
if !s.Geometry.IsUnset() {
vals = append(vals, "geometry")
}
if s.OrganizationID.IsValue() {
vals = append(vals, "organization_id")
}
if s.Resolution.IsValue() {
vals = append(vals, "resolution")
}
if s.Type.IsValue() {
vals = append(vals, "type_")
}
return vals
}
@ -125,18 +134,21 @@ func (s H3AggregationSetter) Overwrite(t *H3Aggregation) {
if s.Cell.IsValue() {
t.Cell = s.Cell.MustGet()
}
if s.Resolution.IsValue() {
t.Resolution = s.Resolution.MustGet()
}
if s.Count.IsValue() {
t.Count = s.Count.MustGet()
}
if s.Type.IsValue() {
t.Type = s.Type.MustGet()
if !s.Geometry.IsUnset() {
t.Geometry = s.Geometry.MustGetNull()
}
if s.OrganizationID.IsValue() {
t.OrganizationID = s.OrganizationID.MustGet()
}
if s.Resolution.IsValue() {
t.Resolution = s.Resolution.MustGet()
}
if s.Type.IsValue() {
t.Type = s.Type.MustGet()
}
}
func (s *H3AggregationSetter) Apply(q *dialect.InsertQuery) {
@ -145,7 +157,7 @@ func (s *H3AggregationSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.Writer, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 6)
vals := make([]bob.Expression, 7)
if s.ID.IsValue() {
vals[0] = psql.Arg(s.ID.MustGet())
} else {
@ -158,30 +170,36 @@ func (s *H3AggregationSetter) Apply(q *dialect.InsertQuery) {
vals[1] = psql.Raw("DEFAULT")
}
if s.Resolution.IsValue() {
vals[2] = psql.Arg(s.Resolution.MustGet())
if s.Count.IsValue() {
vals[2] = psql.Arg(s.Count.MustGet())
} else {
vals[2] = psql.Raw("DEFAULT")
}
if s.Count.IsValue() {
vals[3] = psql.Arg(s.Count.MustGet())
if !s.Geometry.IsUnset() {
vals[3] = psql.Arg(s.Geometry.MustGetNull())
} else {
vals[3] = psql.Raw("DEFAULT")
}
if s.Type.IsValue() {
vals[4] = psql.Arg(s.Type.MustGet())
if s.OrganizationID.IsValue() {
vals[4] = psql.Arg(s.OrganizationID.MustGet())
} else {
vals[4] = psql.Raw("DEFAULT")
}
if s.OrganizationID.IsValue() {
vals[5] = psql.Arg(s.OrganizationID.MustGet())
if s.Resolution.IsValue() {
vals[5] = psql.Arg(s.Resolution.MustGet())
} else {
vals[5] = psql.Raw("DEFAULT")
}
if s.Type.IsValue() {
vals[6] = psql.Arg(s.Type.MustGet())
} else {
vals[6] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -191,7 +209,7 @@ func (s H3AggregationSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s H3AggregationSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 6)
exprs := make([]bob.Expression, 0, 7)
if s.ID.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -207,13 +225,6 @@ func (s H3AggregationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if s.Resolution.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "resolution")...),
psql.Arg(s.Resolution),
}})
}
if s.Count.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "count_")...),
@ -221,10 +232,10 @@ func (s H3AggregationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if s.Type.IsValue() {
if !s.Geometry.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "type_")...),
psql.Arg(s.Type),
psql.Quote(append(prefix, "geometry")...),
psql.Arg(s.Geometry),
}})
}
@ -235,6 +246,20 @@ func (s H3AggregationSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if s.Resolution.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "resolution")...),
psql.Arg(s.Resolution),
}})
}
if s.Type.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "type_")...),
psql.Arg(s.Type),
}})
}
return exprs
}
@ -536,10 +561,11 @@ func (h3Aggregation0 *H3Aggregation) AttachOrganization(ctx context.Context, exe
type h3AggregationWhere[Q psql.Filterable] struct {
ID psql.WhereMod[Q, int32]
Cell psql.WhereMod[Q, string]
Resolution psql.WhereMod[Q, int32]
Count psql.WhereMod[Q, int32]
Type psql.WhereMod[Q, enums.H3aggregationtype]
Geometry psql.WhereNullMod[Q, string]
OrganizationID psql.WhereMod[Q, int32]
Resolution psql.WhereMod[Q, int32]
Type psql.WhereMod[Q, enums.H3aggregationtype]
}
func (h3AggregationWhere[Q]) AliasedAs(alias string) h3AggregationWhere[Q] {
@ -550,10 +576,11 @@ func buildH3AggregationWhere[Q psql.Filterable](cols h3AggregationColumns) h3Agg
return h3AggregationWhere[Q]{
ID: psql.Where[Q, int32](cols.ID),
Cell: psql.Where[Q, string](cols.Cell),
Resolution: psql.Where[Q, int32](cols.Resolution),
Count: psql.Where[Q, int32](cols.Count),
Type: psql.Where[Q, enums.H3aggregationtype](cols.Type),
Geometry: psql.WhereNull[Q, string](cols.Geometry),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
Resolution: psql.Where[Q, int32](cols.Resolution),
Type: psql.Where[Q, enums.H3aggregationtype](cols.Type),
}
}