Remove a bunch of generated bob, add feature and review tasks
This commit is contained in:
parent
662188485e
commit
527e82031e
206 changed files with 5761 additions and 141269 deletions
|
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql/um"
|
||||
"github.com/Gleipnir-Technology/bob/expr"
|
||||
"github.com/Gleipnir-Technology/bob/mods"
|
||||
"github.com/Gleipnir-Technology/bob/orm"
|
||||
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
||||
"github.com/aarondl/opt/null"
|
||||
|
|
@ -32,8 +31,6 @@ type ArcgisServiceFeature struct {
|
|||
AccountID null.Val[string] `db:"account_id" `
|
||||
|
||||
R arcgisServiceFeatureR `db:"-" `
|
||||
|
||||
C arcgisServiceFeatureC `db:"-" `
|
||||
}
|
||||
|
||||
// ArcgisServiceFeatureSlice is an alias for a slice of pointers to ArcgisServiceFeature.
|
||||
|
|
@ -1012,216 +1009,3 @@ func (os ArcgisServiceFeatureSlice) LoadFieldseekerServiceFeatureItemOrganizatio
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// arcgisServiceFeatureC is where relationship counts are stored.
|
||||
type arcgisServiceFeatureC struct {
|
||||
FeatureServiceItemLayers *int64
|
||||
FieldseekerServiceFeatureItemOrganizations *int64
|
||||
}
|
||||
|
||||
// PreloadCount sets a count in the C struct by name
|
||||
func (o *ArcgisServiceFeature) PreloadCount(name string, count int64) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
case "FeatureServiceItemLayers":
|
||||
o.C.FeatureServiceItemLayers = &count
|
||||
case "FieldseekerServiceFeatureItemOrganizations":
|
||||
o.C.FieldseekerServiceFeatureItemOrganizations = &count
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type arcgisServiceFeatureCountPreloader struct {
|
||||
FeatureServiceItemLayers func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
FieldseekerServiceFeatureItemOrganizations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
}
|
||||
|
||||
func buildArcgisServiceFeatureCountPreloader() arcgisServiceFeatureCountPreloader {
|
||||
return arcgisServiceFeatureCountPreloader{
|
||||
FeatureServiceItemLayers: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
|
||||
return countPreloader[*ArcgisServiceFeature]("FeatureServiceItemLayers", func(parent string) bob.Expression {
|
||||
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
|
||||
if parent == "" {
|
||||
parent = ArcgisServiceFeatures.Alias()
|
||||
}
|
||||
|
||||
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
|
||||
sm.Columns(psql.Raw("count(*)")),
|
||||
|
||||
sm.From(ArcgisLayers.Name()),
|
||||
sm.Where(psql.Quote(ArcgisLayers.Alias(), "feature_service_item_id").EQ(psql.Quote(parent, "item_id"))),
|
||||
}
|
||||
subqueryMods = append(subqueryMods, mods...)
|
||||
return psql.Group(psql.Select(subqueryMods...).Expression)
|
||||
})
|
||||
},
|
||||
FieldseekerServiceFeatureItemOrganizations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
|
||||
return countPreloader[*ArcgisServiceFeature]("FieldseekerServiceFeatureItemOrganizations", func(parent string) bob.Expression {
|
||||
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
|
||||
if parent == "" {
|
||||
parent = ArcgisServiceFeatures.Alias()
|
||||
}
|
||||
|
||||
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
|
||||
sm.Columns(psql.Raw("count(*)")),
|
||||
|
||||
sm.From(Organizations.Name()),
|
||||
sm.Where(psql.Quote(Organizations.Alias(), "fieldseeker_service_feature_item_id").EQ(psql.Quote(parent, "item_id"))),
|
||||
}
|
||||
subqueryMods = append(subqueryMods, mods...)
|
||||
return psql.Group(psql.Select(subqueryMods...).Expression)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type arcgisServiceFeatureCountThenLoader[Q orm.Loadable] struct {
|
||||
FeatureServiceItemLayers func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
FieldseekerServiceFeatureItemOrganizations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildArcgisServiceFeatureCountThenLoader[Q orm.Loadable]() arcgisServiceFeatureCountThenLoader[Q] {
|
||||
type FeatureServiceItemLayersCountInterface interface {
|
||||
LoadCountFeatureServiceItemLayers(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type FieldseekerServiceFeatureItemOrganizationsCountInterface interface {
|
||||
LoadCountFieldseekerServiceFeatureItemOrganizations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
||||
return arcgisServiceFeatureCountThenLoader[Q]{
|
||||
FeatureServiceItemLayers: countThenLoadBuilder[Q](
|
||||
"FeatureServiceItemLayers",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved FeatureServiceItemLayersCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadCountFeatureServiceItemLayers(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
FieldseekerServiceFeatureItemOrganizations: countThenLoadBuilder[Q](
|
||||
"FieldseekerServiceFeatureItemOrganizations",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved FieldseekerServiceFeatureItemOrganizationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadCountFieldseekerServiceFeatureItemOrganizations(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// LoadCountFeatureServiceItemLayers loads the count of FeatureServiceItemLayers into the C struct
|
||||
func (o *ArcgisServiceFeature) LoadCountFeatureServiceItemLayers(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
count, err := o.FeatureServiceItemLayers(mods...).Count(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.C.FeatureServiceItemLayers = &count
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCountFeatureServiceItemLayers loads the count of FeatureServiceItemLayers for a slice
|
||||
func (os ArcgisServiceFeatureSlice) LoadCountFeatureServiceItemLayers(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if err := o.LoadCountFeatureServiceItemLayers(ctx, exec, mods...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCountFieldseekerServiceFeatureItemOrganizations loads the count of FieldseekerServiceFeatureItemOrganizations into the C struct
|
||||
func (o *ArcgisServiceFeature) LoadCountFieldseekerServiceFeatureItemOrganizations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
count, err := o.FieldseekerServiceFeatureItemOrganizations(mods...).Count(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.C.FieldseekerServiceFeatureItemOrganizations = &count
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCountFieldseekerServiceFeatureItemOrganizations loads the count of FieldseekerServiceFeatureItemOrganizations for a slice
|
||||
func (os ArcgisServiceFeatureSlice) LoadCountFieldseekerServiceFeatureItemOrganizations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if err := o.LoadCountFieldseekerServiceFeatureItemOrganizations(ctx, exec, mods...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type arcgisServiceFeatureJoins[Q dialect.Joinable] struct {
|
||||
typ string
|
||||
FeatureServiceItemLayers modAs[Q, arcgisLayerColumns]
|
||||
Account modAs[Q, arcgisAccountColumns]
|
||||
FieldseekerServiceFeatureItemOrganizations modAs[Q, organizationColumns]
|
||||
}
|
||||
|
||||
func (j arcgisServiceFeatureJoins[Q]) aliasedAs(alias string) arcgisServiceFeatureJoins[Q] {
|
||||
return buildArcgisServiceFeatureJoins[Q](buildArcgisServiceFeatureColumns(alias), j.typ)
|
||||
}
|
||||
|
||||
func buildArcgisServiceFeatureJoins[Q dialect.Joinable](cols arcgisServiceFeatureColumns, typ string) arcgisServiceFeatureJoins[Q] {
|
||||
return arcgisServiceFeatureJoins[Q]{
|
||||
typ: typ,
|
||||
FeatureServiceItemLayers: modAs[Q, arcgisLayerColumns]{
|
||||
c: ArcgisLayers.Columns,
|
||||
f: func(to arcgisLayerColumns) bob.Mod[Q] {
|
||||
mods := make(mods.QueryMods[Q], 0, 1)
|
||||
|
||||
{
|
||||
mods = append(mods, dialect.Join[Q](typ, ArcgisLayers.Name().As(to.Alias())).On(
|
||||
to.FeatureServiceItemID.EQ(cols.ItemID),
|
||||
))
|
||||
}
|
||||
|
||||
return mods
|
||||
},
|
||||
},
|
||||
Account: modAs[Q, arcgisAccountColumns]{
|
||||
c: ArcgisAccounts.Columns,
|
||||
f: func(to arcgisAccountColumns) bob.Mod[Q] {
|
||||
mods := make(mods.QueryMods[Q], 0, 1)
|
||||
|
||||
{
|
||||
mods = append(mods, dialect.Join[Q](typ, ArcgisAccounts.Name().As(to.Alias())).On(
|
||||
to.ID.EQ(cols.AccountID),
|
||||
))
|
||||
}
|
||||
|
||||
return mods
|
||||
},
|
||||
},
|
||||
FieldseekerServiceFeatureItemOrganizations: modAs[Q, organizationColumns]{
|
||||
c: Organizations.Columns,
|
||||
f: func(to organizationColumns) bob.Mod[Q] {
|
||||
mods := make(mods.QueryMods[Q], 0, 1)
|
||||
|
||||
{
|
||||
mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
|
||||
to.FieldseekerServiceFeatureItemID.EQ(cols.ItemID),
|
||||
))
|
||||
}
|
||||
|
||||
return mods
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue