Make signals include the object they are attached to (pool, report)

This means pushing the types into the common types module, which
required a refactor of a bunch of other libraries.
This commit is contained in:
Eli Ribble 2026-03-21 01:19:36 +00:00
parent ddc63bfa91
commit 9b6cacda0e
No known key found for this signature in database
18 changed files with 1135 additions and 262 deletions

View file

@ -78,15 +78,6 @@ var Signals = Table[
Generated: false,
AutoIncr: false,
},
Title: column{
Name: "title",
DBType: "text",
Default: "",
Comment: "",
Nullable: false,
Generated: false,
AutoIncr: false,
},
Type: column{
Name: "type_",
DBType: "public.signaltype",
@ -123,6 +114,24 @@ var Signals = Table[
Generated: true,
AutoIncr: false,
},
FeaturePoolFeatureID: column{
Name: "feature_pool_feature_id",
DBType: "integer",
Default: "NULL",
Comment: "",
Nullable: true,
Generated: false,
AutoIncr: false,
},
ReportID: column{
Name: "report_id",
DBType: "integer",
Default: "NULL",
Comment: "",
Nullable: true,
Generated: false,
AutoIncr: false,
},
},
Indexes: signalIndexes{
SignalPkey: index{
@ -201,6 +210,15 @@ var Signals = Table[
ForeignTable: "user_",
ForeignColumns: []string{"id"},
},
SignalSignalFeaturePoolFeatureIDFkey: foreignKey{
constraint: constraint{
Name: "signal.signal_feature_pool_feature_id_fkey",
Columns: []string{"feature_pool_feature_id"},
Comment: "",
},
ForeignTable: "feature_pool",
ForeignColumns: []string{"feature_id"},
},
SignalSignalOrganizationIDFkey: foreignKey{
constraint: constraint{
Name: "signal.signal_organization_id_fkey",
@ -210,6 +228,15 @@ var Signals = Table[
ForeignTable: "organization",
ForeignColumns: []string{"id"},
},
SignalSignalReportIDFkey: foreignKey{
constraint: constraint{
Name: "signal.signal_report_id_fkey",
Columns: []string{"report_id"},
Comment: "",
},
ForeignTable: "publicreport.report",
ForeignColumns: []string{"id"},
},
SignalSignalSiteIDFkey: foreignKey{
constraint: constraint{
Name: "signal.signal_site_id_fkey",
@ -222,6 +249,14 @@ var Signals = Table[
},
Checks: signalChecks{
CheckExclusiveReference: check{
constraint: constraint{
Name: "check_exclusive_reference",
Columns: []string{"feature_pool_feature_id", "report_id"},
Comment: "",
},
Expression: "((feature_pool_feature_id IS NULL) OR (report_id IS NULL))",
},
ValidLocationTypes: check{
constraint: constraint{
Name: "valid_location_types",
@ -235,23 +270,24 @@ var Signals = Table[
}
type signalColumns struct {
Addressed column
Addressor column
Created column
Creator column
ID column
OrganizationID column
Species column
Title column
Type column
SiteID column
Location column
LocationType column
Addressed column
Addressor column
Created column
Creator column
ID column
OrganizationID column
Species column
Type column
SiteID column
Location column
LocationType column
FeaturePoolFeatureID column
ReportID column
}
func (c signalColumns) AsSlice() []column {
return []column{
c.Addressed, c.Addressor, c.Created, c.Creator, c.ID, c.OrganizationID, c.Species, c.Title, c.Type, c.SiteID, c.Location, c.LocationType,
c.Addressed, c.Addressor, c.Created, c.Creator, c.ID, c.OrganizationID, c.Species, c.Type, c.SiteID, c.Location, c.LocationType, c.FeaturePoolFeatureID, c.ReportID,
}
}
@ -268,15 +304,17 @@ func (i signalIndexes) AsSlice() []index {
}
type signalForeignKeys struct {
SignalSignalAddressorFkey foreignKey
SignalSignalCreatorFkey foreignKey
SignalSignalOrganizationIDFkey foreignKey
SignalSignalSiteIDFkey foreignKey
SignalSignalAddressorFkey foreignKey
SignalSignalCreatorFkey foreignKey
SignalSignalFeaturePoolFeatureIDFkey foreignKey
SignalSignalOrganizationIDFkey foreignKey
SignalSignalReportIDFkey foreignKey
SignalSignalSiteIDFkey foreignKey
}
func (f signalForeignKeys) AsSlice() []foreignKey {
return []foreignKey{
f.SignalSignalAddressorFkey, f.SignalSignalCreatorFkey, f.SignalSignalOrganizationIDFkey, f.SignalSignalSiteIDFkey,
f.SignalSignalAddressorFkey, f.SignalSignalCreatorFkey, f.SignalSignalFeaturePoolFeatureIDFkey, f.SignalSignalOrganizationIDFkey, f.SignalSignalReportIDFkey, f.SignalSignalSiteIDFkey,
}
}
@ -287,11 +325,12 @@ func (u signalUniques) AsSlice() []constraint {
}
type signalChecks struct {
ValidLocationTypes check
CheckExclusiveReference check
ValidLocationTypes check
}
func (c signalChecks) AsSlice() []check {
return []check{
c.ValidLocationTypes,
c.CheckExclusiveReference, c.ValidLocationTypes,
}
}

View file

@ -0,0 +1,4 @@
-- +goose up
ALTER TABLE signal DROP COLUMN title;
-- +goose down
ALTER TABLE signal ADD COLUMN title TEXT NOT NULL;

View file

@ -0,0 +1,12 @@
-- +goose Up
ALTER TABLE signal ADD COLUMN feature_pool_feature_id INTEGER REFERENCES feature_pool(feature_id);
ALTER TABLE signal ADD COLUMN report_id INTEGER REFERENCES publicreport.report(id);
ALTER TABLE signal
ADD CONSTRAINT check_exclusive_reference
CHECK (
(feature_pool_feature_id IS NULL OR report_id IS NULL)
);
-- +goose Down
ALTER TABLE signal DROP CONSTRAINT check_exclusive_reference;
ALTER TABLE signal DROP COLUMN report_id;
ALTER TABLE signal DROP COLUMN feature_pool_feature_id;

View file

@ -45,8 +45,9 @@ type FeaturePoolsQuery = *psql.ViewQuery[*FeaturePool, FeaturePoolSlice]
// featurePoolR is where relationships are stored.
type featurePoolR struct {
Feature *Feature // feature_pool.feature_pool_feature_id_fkey
ReviewTaskPools ReviewTaskPoolSlice // review_task_pool.review_task_pool_feature_pool_fkey
Feature *Feature // feature_pool.feature_pool_feature_id_fkey
ReviewTaskPools ReviewTaskPoolSlice // review_task_pool.review_task_pool_feature_pool_fkey
FeaturePoolFeatureSignals SignalSlice // signal.signal_feature_pool_feature_id_fkey
}
func buildFeaturePoolColumns(alias string) featurePoolColumns {
@ -465,6 +466,30 @@ func (os FeaturePoolSlice) ReviewTaskPools(mods ...bob.Mod[*dialect.SelectQuery]
)...)
}
// FeaturePoolFeatureSignals starts a query for related objects on signal
func (o *FeaturePool) FeaturePoolFeatureSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
return Signals.Query(append(mods,
sm.Where(Signals.Columns.FeaturePoolFeatureID.EQ(psql.Arg(o.FeatureID))),
)...)
}
func (os FeaturePoolSlice) FeaturePoolFeatureSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
pkFeatureID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
continue
}
pkFeatureID = append(pkFeatureID, o.FeatureID)
}
PKArgExpr := psql.Select(sm.Columns(
psql.F("unnest", psql.Cast(psql.Arg(pkFeatureID), "integer[]")),
))
return Signals.Query(append(mods,
sm.Where(psql.Group(Signals.Columns.FeaturePoolFeatureID).OP("IN", PKArgExpr)),
)...)
}
func attachFeaturePoolFeature0(ctx context.Context, exec bob.Executor, count int, featurePool0 *FeaturePool, feature1 *Feature) (*FeaturePool, error) {
setter := &FeaturePoolSetter{
FeatureID: omit.From(feature1.ID),
@ -581,6 +606,74 @@ func (featurePool0 *FeaturePool) AttachReviewTaskPools(ctx context.Context, exec
return nil
}
func insertFeaturePoolFeaturePoolFeatureSignals0(ctx context.Context, exec bob.Executor, signals1 []*SignalSetter, featurePool0 *FeaturePool) (SignalSlice, error) {
for i := range signals1 {
signals1[i].FeaturePoolFeatureID = omitnull.From(featurePool0.FeatureID)
}
ret, err := Signals.Insert(bob.ToMods(signals1...)).All(ctx, exec)
if err != nil {
return ret, fmt.Errorf("insertFeaturePoolFeaturePoolFeatureSignals0: %w", err)
}
return ret, nil
}
func attachFeaturePoolFeaturePoolFeatureSignals0(ctx context.Context, exec bob.Executor, count int, signals1 SignalSlice, featurePool0 *FeaturePool) (SignalSlice, error) {
setter := &SignalSetter{
FeaturePoolFeatureID: omitnull.From(featurePool0.FeatureID),
}
err := signals1.UpdateAll(ctx, exec, *setter)
if err != nil {
return nil, fmt.Errorf("attachFeaturePoolFeaturePoolFeatureSignals0: %w", err)
}
return signals1, nil
}
func (featurePool0 *FeaturePool) InsertFeaturePoolFeatureSignals(ctx context.Context, exec bob.Executor, related ...*SignalSetter) error {
if len(related) == 0 {
return nil
}
var err error
signals1, err := insertFeaturePoolFeaturePoolFeatureSignals0(ctx, exec, related, featurePool0)
if err != nil {
return err
}
featurePool0.R.FeaturePoolFeatureSignals = append(featurePool0.R.FeaturePoolFeatureSignals, signals1...)
for _, rel := range signals1 {
rel.R.FeaturePoolFeatureFeaturePool = featurePool0
}
return nil
}
func (featurePool0 *FeaturePool) AttachFeaturePoolFeatureSignals(ctx context.Context, exec bob.Executor, related ...*Signal) error {
if len(related) == 0 {
return nil
}
var err error
signals1 := SignalSlice(related)
_, err = attachFeaturePoolFeaturePoolFeatureSignals0(ctx, exec, len(related), signals1, featurePool0)
if err != nil {
return err
}
featurePool0.R.FeaturePoolFeatureSignals = append(featurePool0.R.FeaturePoolFeatureSignals, signals1...)
for _, rel := range related {
rel.R.FeaturePoolFeatureFeaturePool = featurePool0
}
return nil
}
type featurePoolWhere[Q psql.Filterable] struct {
FeatureID psql.WhereMod[Q, int32]
Condition psql.WhereMod[Q, enums.Poolconditiontype]
@ -633,6 +726,20 @@ func (o *FeaturePool) Preload(name string, retrieved any) error {
}
}
return nil
case "FeaturePoolFeatureSignals":
rels, ok := retrieved.(SignalSlice)
if !ok {
return fmt.Errorf("featurePool cannot load %T as %q", retrieved, name)
}
o.R.FeaturePoolFeatureSignals = rels
for _, rel := range rels {
if rel != nil {
rel.R.FeaturePoolFeatureFeaturePool = o
}
}
return nil
default:
return fmt.Errorf("featurePool has no relationship %q", name)
}
@ -661,8 +768,9 @@ func buildFeaturePoolPreloader() featurePoolPreloader {
}
type featurePoolThenLoader[Q orm.Loadable] struct {
Feature func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
ReviewTaskPools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Feature func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
ReviewTaskPools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
FeaturePoolFeatureSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildFeaturePoolThenLoader[Q orm.Loadable]() featurePoolThenLoader[Q] {
@ -672,6 +780,9 @@ func buildFeaturePoolThenLoader[Q orm.Loadable]() featurePoolThenLoader[Q] {
type ReviewTaskPoolsLoadInterface interface {
LoadReviewTaskPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type FeaturePoolFeatureSignalsLoadInterface interface {
LoadFeaturePoolFeatureSignals(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return featurePoolThenLoader[Q]{
Feature: thenLoadBuilder[Q](
@ -686,6 +797,12 @@ func buildFeaturePoolThenLoader[Q orm.Loadable]() featurePoolThenLoader[Q] {
return retrieved.LoadReviewTaskPools(ctx, exec, mods...)
},
),
FeaturePoolFeatureSignals: thenLoadBuilder[Q](
"FeaturePoolFeatureSignals",
func(ctx context.Context, exec bob.Executor, retrieved FeaturePoolFeatureSignalsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadFeaturePoolFeatureSignals(ctx, exec, mods...)
},
),
}
}
@ -801,3 +918,67 @@ func (os FeaturePoolSlice) LoadReviewTaskPools(ctx context.Context, exec bob.Exe
return nil
}
// LoadFeaturePoolFeatureSignals loads the featurePool's FeaturePoolFeatureSignals into the .R struct
func (o *FeaturePool) LoadFeaturePoolFeatureSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
o.R.FeaturePoolFeatureSignals = nil
related, err := o.FeaturePoolFeatureSignals(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, rel := range related {
rel.R.FeaturePoolFeatureFeaturePool = o
}
o.R.FeaturePoolFeatureSignals = related
return nil
}
// LoadFeaturePoolFeatureSignals loads the featurePool's FeaturePoolFeatureSignals into the .R struct
func (os FeaturePoolSlice) LoadFeaturePoolFeatureSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
signals, err := os.FeaturePoolFeatureSignals(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, o := range os {
if o == nil {
continue
}
o.R.FeaturePoolFeatureSignals = nil
}
for _, o := range os {
if o == nil {
continue
}
for _, rel := range signals {
if !rel.FeaturePoolFeatureID.IsValue() {
continue
}
if !(rel.FeaturePoolFeatureID.IsValue() && o.FeatureID == rel.FeaturePoolFeatureID.MustGet()) {
continue
}
rel.R.FeaturePoolFeatureFeaturePool = o
o.R.FeaturePoolFeatureSignals = append(o.R.FeaturePoolFeatureSignals, rel)
}
}
return nil
}

View file

@ -81,6 +81,7 @@ type publicreportReportR struct {
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_report_id_fkey
Water *PublicreportWater // publicreport.water.water_report_id_fkey
ReportTexts ReportTextSlice // report_text.report_text_report_id_fkey
Signals SignalSlice // signal.signal_report_id_fkey
}
func buildPublicreportReportColumns(alias string) publicreportReportColumns {
@ -1186,6 +1187,30 @@ func (os PublicreportReportSlice) ReportTexts(mods ...bob.Mod[*dialect.SelectQue
)...)
}
// Signals starts a query for related objects on signal
func (o *PublicreportReport) Signals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
return Signals.Query(append(mods,
sm.Where(Signals.Columns.ReportID.EQ(psql.Arg(o.ID))),
)...)
}
func (os PublicreportReportSlice) Signals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
pkID := make(pgtypes.Array[int32], 0, len(os))
for _, o := range os {
if o == nil {
continue
}
pkID = append(pkID, o.ID)
}
PKArgExpr := psql.Select(sm.Columns(
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
))
return Signals.Query(append(mods,
sm.Where(psql.Group(Signals.Columns.ReportID).OP("IN", PKArgExpr)),
)...)
}
func insertPublicreportReportTextJobs0(ctx context.Context, exec bob.Executor, commsTextJobs1 []*CommsTextJobSetter, publicreportReport0 *PublicreportReport) (CommsTextJobSlice, error) {
for i := range commsTextJobs1 {
commsTextJobs1[i].ReportID = omitnull.From(publicreportReport0.ID)
@ -1843,6 +1868,74 @@ func (publicreportReport0 *PublicreportReport) AttachReportTexts(ctx context.Con
return nil
}
func insertPublicreportReportSignals0(ctx context.Context, exec bob.Executor, signals1 []*SignalSetter, publicreportReport0 *PublicreportReport) (SignalSlice, error) {
for i := range signals1 {
signals1[i].ReportID = omitnull.From(publicreportReport0.ID)
}
ret, err := Signals.Insert(bob.ToMods(signals1...)).All(ctx, exec)
if err != nil {
return ret, fmt.Errorf("insertPublicreportReportSignals0: %w", err)
}
return ret, nil
}
func attachPublicreportReportSignals0(ctx context.Context, exec bob.Executor, count int, signals1 SignalSlice, publicreportReport0 *PublicreportReport) (SignalSlice, error) {
setter := &SignalSetter{
ReportID: omitnull.From(publicreportReport0.ID),
}
err := signals1.UpdateAll(ctx, exec, *setter)
if err != nil {
return nil, fmt.Errorf("attachPublicreportReportSignals0: %w", err)
}
return signals1, nil
}
func (publicreportReport0 *PublicreportReport) InsertSignals(ctx context.Context, exec bob.Executor, related ...*SignalSetter) error {
if len(related) == 0 {
return nil
}
var err error
signals1, err := insertPublicreportReportSignals0(ctx, exec, related, publicreportReport0)
if err != nil {
return err
}
publicreportReport0.R.Signals = append(publicreportReport0.R.Signals, signals1...)
for _, rel := range signals1 {
rel.R.Report = publicreportReport0
}
return nil
}
func (publicreportReport0 *PublicreportReport) AttachSignals(ctx context.Context, exec bob.Executor, related ...*Signal) error {
if len(related) == 0 {
return nil
}
var err error
signals1 := SignalSlice(related)
_, err = attachPublicreportReportSignals0(ctx, exec, len(related), signals1, publicreportReport0)
if err != nil {
return err
}
publicreportReport0.R.Signals = append(publicreportReport0.R.Signals, signals1...)
for _, rel := range related {
rel.R.Report = publicreportReport0
}
return nil
}
type publicreportReportWhere[Q psql.Filterable] struct {
AddressRaw psql.WhereMod[Q, string]
AddressNumber psql.WhereMod[Q, string]
@ -2053,6 +2146,20 @@ func (o *PublicreportReport) Preload(name string, retrieved any) error {
o.R.ReportTexts = rels
for _, rel := range rels {
if rel != nil {
rel.R.Report = o
}
}
return nil
case "Signals":
rels, ok := retrieved.(SignalSlice)
if !ok {
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
}
o.R.Signals = rels
for _, rel := range rels {
if rel != nil {
rel.R.Report = o
@ -2154,6 +2261,7 @@ type publicreportReportThenLoader[Q orm.Loadable] struct {
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Water func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
ReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Signals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildPublicreportReportThenLoader[Q orm.Loadable]() publicreportReportThenLoader[Q] {
@ -2190,6 +2298,9 @@ func buildPublicreportReportThenLoader[Q orm.Loadable]() publicreportReportThenL
type ReportTextsLoadInterface interface {
LoadReportTexts(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type SignalsLoadInterface interface {
LoadSignals(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
return publicreportReportThenLoader[Q]{
TextJobs: thenLoadBuilder[Q](
@ -2258,6 +2369,12 @@ func buildPublicreportReportThenLoader[Q orm.Loadable]() publicreportReportThenL
return retrieved.LoadReportTexts(ctx, exec, mods...)
},
),
Signals: thenLoadBuilder[Q](
"Signals",
func(ctx context.Context, exec bob.Executor, retrieved SignalsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadSignals(ctx, exec, mods...)
},
),
}
}
@ -2915,3 +3032,67 @@ func (os PublicreportReportSlice) LoadReportTexts(ctx context.Context, exec bob.
return nil
}
// LoadSignals loads the publicreportReport's Signals into the .R struct
func (o *PublicreportReport) LoadSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
o.R.Signals = nil
related, err := o.Signals(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, rel := range related {
rel.R.Report = o
}
o.R.Signals = related
return nil
}
// LoadSignals loads the publicreportReport's Signals into the .R struct
func (os PublicreportReportSlice) LoadSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
signals, err := os.Signals(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, o := range os {
if o == nil {
continue
}
o.R.Signals = nil
}
for _, o := range os {
if o == nil {
continue
}
for _, rel := range signals {
if !rel.ReportID.IsValue() {
continue
}
if !(rel.ReportID.IsValue() && o.ID == rel.ReportID.MustGet()) {
continue
}
rel.R.Report = o
o.R.Signals = append(o.R.Signals, rel)
}
}
return nil
}

View file

@ -26,18 +26,19 @@ import (
// Signal is an object representing the database table.
type Signal struct {
Addressed null.Val[time.Time] `db:"addressed" `
Addressor null.Val[int32] `db:"addressor" `
Created time.Time `db:"created" `
Creator int32 `db:"creator" `
ID int32 `db:"id,pk" `
OrganizationID int32 `db:"organization_id" `
Species null.Val[enums.Mosquitospecies] `db:"species" `
Title string `db:"title" `
Type enums.Signaltype `db:"type_" `
SiteID null.Val[int32] `db:"site_id" `
Location string `db:"location" `
LocationType null.Val[string] `db:"location_type,generated" `
Addressed null.Val[time.Time] `db:"addressed" `
Addressor null.Val[int32] `db:"addressor" `
Created time.Time `db:"created" `
Creator int32 `db:"creator" `
ID int32 `db:"id,pk" `
OrganizationID int32 `db:"organization_id" `
Species null.Val[enums.Mosquitospecies] `db:"species" `
Type enums.Signaltype `db:"type_" `
SiteID null.Val[int32] `db:"site_id" `
Location string `db:"location" `
LocationType null.Val[string] `db:"location_type,generated" `
FeaturePoolFeatureID null.Val[int32] `db:"feature_pool_feature_id" `
ReportID null.Val[int32] `db:"report_id" `
R signalR `db:"-" `
}
@ -54,48 +55,52 @@ type SignalsQuery = *psql.ViewQuery[*Signal, SignalSlice]
// signalR is where relationships are stored.
type signalR struct {
AddressorUser *User // signal.signal_addressor_fkey
CreatorUser *User // signal.signal_creator_fkey
Organization *Organization // signal.signal_organization_id_fkey
Site *Site // signal.signal_site_id_fkey
AddressorUser *User // signal.signal_addressor_fkey
CreatorUser *User // signal.signal_creator_fkey
FeaturePoolFeatureFeaturePool *FeaturePool // signal.signal_feature_pool_feature_id_fkey
Organization *Organization // signal.signal_organization_id_fkey
Report *PublicreportReport // signal.signal_report_id_fkey
Site *Site // signal.signal_site_id_fkey
}
func buildSignalColumns(alias string) signalColumns {
return signalColumns{
ColumnsExpr: expr.NewColumnsExpr(
"addressed", "addressor", "created", "creator", "id", "organization_id", "species", "title", "type_", "site_id", "location", "location_type",
"addressed", "addressor", "created", "creator", "id", "organization_id", "species", "type_", "site_id", "location", "location_type", "feature_pool_feature_id", "report_id",
).WithParent("signal"),
tableAlias: alias,
Addressed: psql.Quote(alias, "addressed"),
Addressor: psql.Quote(alias, "addressor"),
Created: psql.Quote(alias, "created"),
Creator: psql.Quote(alias, "creator"),
ID: psql.Quote(alias, "id"),
OrganizationID: psql.Quote(alias, "organization_id"),
Species: psql.Quote(alias, "species"),
Title: psql.Quote(alias, "title"),
Type: psql.Quote(alias, "type_"),
SiteID: psql.Quote(alias, "site_id"),
Location: psql.Quote(alias, "location"),
LocationType: psql.Quote(alias, "location_type"),
tableAlias: alias,
Addressed: psql.Quote(alias, "addressed"),
Addressor: psql.Quote(alias, "addressor"),
Created: psql.Quote(alias, "created"),
Creator: psql.Quote(alias, "creator"),
ID: psql.Quote(alias, "id"),
OrganizationID: psql.Quote(alias, "organization_id"),
Species: psql.Quote(alias, "species"),
Type: psql.Quote(alias, "type_"),
SiteID: psql.Quote(alias, "site_id"),
Location: psql.Quote(alias, "location"),
LocationType: psql.Quote(alias, "location_type"),
FeaturePoolFeatureID: psql.Quote(alias, "feature_pool_feature_id"),
ReportID: psql.Quote(alias, "report_id"),
}
}
type signalColumns struct {
expr.ColumnsExpr
tableAlias string
Addressed psql.Expression
Addressor psql.Expression
Created psql.Expression
Creator psql.Expression
ID psql.Expression
OrganizationID psql.Expression
Species psql.Expression
Title psql.Expression
Type psql.Expression
SiteID psql.Expression
Location psql.Expression
LocationType psql.Expression
tableAlias string
Addressed psql.Expression
Addressor psql.Expression
Created psql.Expression
Creator psql.Expression
ID psql.Expression
OrganizationID psql.Expression
Species psql.Expression
Type psql.Expression
SiteID psql.Expression
Location psql.Expression
LocationType psql.Expression
FeaturePoolFeatureID psql.Expression
ReportID psql.Expression
}
func (c signalColumns) Alias() string {
@ -110,21 +115,22 @@ func (signalColumns) AliasedAs(alias string) signalColumns {
// All values are optional, and do not have to be set
// Generated columns are not included
type SignalSetter struct {
Addressed omitnull.Val[time.Time] `db:"addressed" `
Addressor omitnull.Val[int32] `db:"addressor" `
Created omit.Val[time.Time] `db:"created" `
Creator omit.Val[int32] `db:"creator" `
ID omit.Val[int32] `db:"id,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Species omitnull.Val[enums.Mosquitospecies] `db:"species" `
Title omit.Val[string] `db:"title" `
Type omit.Val[enums.Signaltype] `db:"type_" `
SiteID omitnull.Val[int32] `db:"site_id" `
Location omit.Val[string] `db:"location" `
Addressed omitnull.Val[time.Time] `db:"addressed" `
Addressor omitnull.Val[int32] `db:"addressor" `
Created omit.Val[time.Time] `db:"created" `
Creator omit.Val[int32] `db:"creator" `
ID omit.Val[int32] `db:"id,pk" `
OrganizationID omit.Val[int32] `db:"organization_id" `
Species omitnull.Val[enums.Mosquitospecies] `db:"species" `
Type omit.Val[enums.Signaltype] `db:"type_" `
SiteID omitnull.Val[int32] `db:"site_id" `
Location omit.Val[string] `db:"location" `
FeaturePoolFeatureID omitnull.Val[int32] `db:"feature_pool_feature_id" `
ReportID omitnull.Val[int32] `db:"report_id" `
}
func (s SignalSetter) SetColumns() []string {
vals := make([]string, 0, 11)
vals := make([]string, 0, 12)
if !s.Addressed.IsUnset() {
vals = append(vals, "addressed")
}
@ -146,9 +152,6 @@ func (s SignalSetter) SetColumns() []string {
if !s.Species.IsUnset() {
vals = append(vals, "species")
}
if s.Title.IsValue() {
vals = append(vals, "title")
}
if s.Type.IsValue() {
vals = append(vals, "type_")
}
@ -158,6 +161,12 @@ func (s SignalSetter) SetColumns() []string {
if s.Location.IsValue() {
vals = append(vals, "location")
}
if !s.FeaturePoolFeatureID.IsUnset() {
vals = append(vals, "feature_pool_feature_id")
}
if !s.ReportID.IsUnset() {
vals = append(vals, "report_id")
}
return vals
}
@ -183,9 +192,6 @@ func (s SignalSetter) Overwrite(t *Signal) {
if !s.Species.IsUnset() {
t.Species = s.Species.MustGetNull()
}
if s.Title.IsValue() {
t.Title = s.Title.MustGet()
}
if s.Type.IsValue() {
t.Type = s.Type.MustGet()
}
@ -195,6 +201,12 @@ func (s SignalSetter) Overwrite(t *Signal) {
if s.Location.IsValue() {
t.Location = s.Location.MustGet()
}
if !s.FeaturePoolFeatureID.IsUnset() {
t.FeaturePoolFeatureID = s.FeaturePoolFeatureID.MustGetNull()
}
if !s.ReportID.IsUnset() {
t.ReportID = s.ReportID.MustGetNull()
}
}
func (s *SignalSetter) Apply(q *dialect.InsertQuery) {
@ -203,7 +215,7 @@ func (s *SignalSetter) Apply(q *dialect.InsertQuery) {
})
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
vals := make([]bob.Expression, 11)
vals := make([]bob.Expression, 12)
if !s.Addressed.IsUnset() {
vals[0] = psql.Arg(s.Addressed.MustGetNull())
} else {
@ -246,30 +258,36 @@ func (s *SignalSetter) Apply(q *dialect.InsertQuery) {
vals[6] = psql.Raw("DEFAULT")
}
if s.Title.IsValue() {
vals[7] = psql.Arg(s.Title.MustGet())
if s.Type.IsValue() {
vals[7] = psql.Arg(s.Type.MustGet())
} else {
vals[7] = psql.Raw("DEFAULT")
}
if s.Type.IsValue() {
vals[8] = psql.Arg(s.Type.MustGet())
if !s.SiteID.IsUnset() {
vals[8] = psql.Arg(s.SiteID.MustGetNull())
} else {
vals[8] = psql.Raw("DEFAULT")
}
if !s.SiteID.IsUnset() {
vals[9] = psql.Arg(s.SiteID.MustGetNull())
if s.Location.IsValue() {
vals[9] = psql.Arg(s.Location.MustGet())
} else {
vals[9] = psql.Raw("DEFAULT")
}
if s.Location.IsValue() {
vals[10] = psql.Arg(s.Location.MustGet())
if !s.FeaturePoolFeatureID.IsUnset() {
vals[10] = psql.Arg(s.FeaturePoolFeatureID.MustGetNull())
} else {
vals[10] = psql.Raw("DEFAULT")
}
if !s.ReportID.IsUnset() {
vals[11] = psql.Arg(s.ReportID.MustGetNull())
} else {
vals[11] = psql.Raw("DEFAULT")
}
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
}))
}
@ -279,7 +297,7 @@ func (s SignalSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
}
func (s SignalSetter) Expressions(prefix ...string) []bob.Expression {
exprs := make([]bob.Expression, 0, 11)
exprs := make([]bob.Expression, 0, 12)
if !s.Addressed.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
@ -330,13 +348,6 @@ func (s SignalSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if s.Title.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "title")...),
psql.Arg(s.Title),
}})
}
if s.Type.IsValue() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "type_")...),
@ -358,6 +369,20 @@ func (s SignalSetter) Expressions(prefix ...string) []bob.Expression {
}})
}
if !s.FeaturePoolFeatureID.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "feature_pool_feature_id")...),
psql.Arg(s.FeaturePoolFeatureID),
}})
}
if !s.ReportID.IsUnset() {
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
psql.Quote(append(prefix, "report_id")...),
psql.Arg(s.ReportID),
}})
}
return exprs
}
@ -632,6 +657,30 @@ func (os SignalSlice) CreatorUser(mods ...bob.Mod[*dialect.SelectQuery]) UsersQu
)...)
}
// FeaturePoolFeatureFeaturePool starts a query for related objects on feature_pool
func (o *Signal) FeaturePoolFeatureFeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
return FeaturePools.Query(append(mods,
sm.Where(FeaturePools.Columns.FeatureID.EQ(psql.Arg(o.FeaturePoolFeatureID))),
)...)
}
func (os SignalSlice) FeaturePoolFeatureFeaturePool(mods ...bob.Mod[*dialect.SelectQuery]) FeaturePoolsQuery {
pkFeaturePoolFeatureID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
for _, o := range os {
if o == nil {
continue
}
pkFeaturePoolFeatureID = append(pkFeaturePoolFeatureID, o.FeaturePoolFeatureID)
}
PKArgExpr := psql.Select(sm.Columns(
psql.F("unnest", psql.Cast(psql.Arg(pkFeaturePoolFeatureID), "integer[]")),
))
return FeaturePools.Query(append(mods,
sm.Where(psql.Group(FeaturePools.Columns.FeatureID).OP("IN", PKArgExpr)),
)...)
}
// Organization starts a query for related objects on organization
func (o *Signal) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
return Organizations.Query(append(mods,
@ -656,6 +705,30 @@ func (os SignalSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) Organi
)...)
}
// Report starts a query for related objects on publicreport.report
func (o *Signal) Report(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportsQuery {
return PublicreportReports.Query(append(mods,
sm.Where(PublicreportReports.Columns.ID.EQ(psql.Arg(o.ReportID))),
)...)
}
func (os SignalSlice) Report(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportsQuery {
pkReportID := make(pgtypes.Array[null.Val[int32]], 0, len(os))
for _, o := range os {
if o == nil {
continue
}
pkReportID = append(pkReportID, o.ReportID)
}
PKArgExpr := psql.Select(sm.Columns(
psql.F("unnest", psql.Cast(psql.Arg(pkReportID), "integer[]")),
))
return PublicreportReports.Query(append(mods,
sm.Where(psql.Group(PublicreportReports.Columns.ID).OP("IN", PKArgExpr)),
)...)
}
// Site starts a query for related objects on site
func (o *Signal) Site(mods ...bob.Mod[*dialect.SelectQuery]) SitesQuery {
return Sites.Query(append(mods,
@ -776,6 +849,54 @@ func (signal0 *Signal) AttachCreatorUser(ctx context.Context, exec bob.Executor,
return nil
}
func attachSignalFeaturePoolFeatureFeaturePool0(ctx context.Context, exec bob.Executor, count int, signal0 *Signal, featurePool1 *FeaturePool) (*Signal, error) {
setter := &SignalSetter{
FeaturePoolFeatureID: omitnull.From(featurePool1.FeatureID),
}
err := signal0.Update(ctx, exec, setter)
if err != nil {
return nil, fmt.Errorf("attachSignalFeaturePoolFeatureFeaturePool0: %w", err)
}
return signal0, nil
}
func (signal0 *Signal) InsertFeaturePoolFeatureFeaturePool(ctx context.Context, exec bob.Executor, related *FeaturePoolSetter) error {
var err error
featurePool1, err := FeaturePools.Insert(related).One(ctx, exec)
if err != nil {
return fmt.Errorf("inserting related objects: %w", err)
}
_, err = attachSignalFeaturePoolFeatureFeaturePool0(ctx, exec, 1, signal0, featurePool1)
if err != nil {
return err
}
signal0.R.FeaturePoolFeatureFeaturePool = featurePool1
featurePool1.R.FeaturePoolFeatureSignals = append(featurePool1.R.FeaturePoolFeatureSignals, signal0)
return nil
}
func (signal0 *Signal) AttachFeaturePoolFeatureFeaturePool(ctx context.Context, exec bob.Executor, featurePool1 *FeaturePool) error {
var err error
_, err = attachSignalFeaturePoolFeatureFeaturePool0(ctx, exec, 1, signal0, featurePool1)
if err != nil {
return err
}
signal0.R.FeaturePoolFeatureFeaturePool = featurePool1
featurePool1.R.FeaturePoolFeatureSignals = append(featurePool1.R.FeaturePoolFeatureSignals, signal0)
return nil
}
func attachSignalOrganization0(ctx context.Context, exec bob.Executor, count int, signal0 *Signal, organization1 *Organization) (*Signal, error) {
setter := &SignalSetter{
OrganizationID: omit.From(organization1.ID),
@ -824,6 +945,54 @@ func (signal0 *Signal) AttachOrganization(ctx context.Context, exec bob.Executor
return nil
}
func attachSignalReport0(ctx context.Context, exec bob.Executor, count int, signal0 *Signal, publicreportReport1 *PublicreportReport) (*Signal, error) {
setter := &SignalSetter{
ReportID: omitnull.From(publicreportReport1.ID),
}
err := signal0.Update(ctx, exec, setter)
if err != nil {
return nil, fmt.Errorf("attachSignalReport0: %w", err)
}
return signal0, nil
}
func (signal0 *Signal) InsertReport(ctx context.Context, exec bob.Executor, related *PublicreportReportSetter) error {
var err error
publicreportReport1, err := PublicreportReports.Insert(related).One(ctx, exec)
if err != nil {
return fmt.Errorf("inserting related objects: %w", err)
}
_, err = attachSignalReport0(ctx, exec, 1, signal0, publicreportReport1)
if err != nil {
return err
}
signal0.R.Report = publicreportReport1
publicreportReport1.R.Signals = append(publicreportReport1.R.Signals, signal0)
return nil
}
func (signal0 *Signal) AttachReport(ctx context.Context, exec bob.Executor, publicreportReport1 *PublicreportReport) error {
var err error
_, err = attachSignalReport0(ctx, exec, 1, signal0, publicreportReport1)
if err != nil {
return err
}
signal0.R.Report = publicreportReport1
publicreportReport1.R.Signals = append(publicreportReport1.R.Signals, signal0)
return nil
}
func attachSignalSite0(ctx context.Context, exec bob.Executor, count int, signal0 *Signal, site1 *Site) (*Signal, error) {
setter := &SignalSetter{
SiteID: omitnull.From(site1.ID),
@ -873,18 +1042,19 @@ func (signal0 *Signal) AttachSite(ctx context.Context, exec bob.Executor, site1
}
type signalWhere[Q psql.Filterable] struct {
Addressed psql.WhereNullMod[Q, time.Time]
Addressor psql.WhereNullMod[Q, int32]
Created psql.WhereMod[Q, time.Time]
Creator psql.WhereMod[Q, int32]
ID psql.WhereMod[Q, int32]
OrganizationID psql.WhereMod[Q, int32]
Species psql.WhereNullMod[Q, enums.Mosquitospecies]
Title psql.WhereMod[Q, string]
Type psql.WhereMod[Q, enums.Signaltype]
SiteID psql.WhereNullMod[Q, int32]
Location psql.WhereMod[Q, string]
LocationType psql.WhereNullMod[Q, string]
Addressed psql.WhereNullMod[Q, time.Time]
Addressor psql.WhereNullMod[Q, int32]
Created psql.WhereMod[Q, time.Time]
Creator psql.WhereMod[Q, int32]
ID psql.WhereMod[Q, int32]
OrganizationID psql.WhereMod[Q, int32]
Species psql.WhereNullMod[Q, enums.Mosquitospecies]
Type psql.WhereMod[Q, enums.Signaltype]
SiteID psql.WhereNullMod[Q, int32]
Location psql.WhereMod[Q, string]
LocationType psql.WhereNullMod[Q, string]
FeaturePoolFeatureID psql.WhereNullMod[Q, int32]
ReportID psql.WhereNullMod[Q, int32]
}
func (signalWhere[Q]) AliasedAs(alias string) signalWhere[Q] {
@ -893,18 +1063,19 @@ func (signalWhere[Q]) AliasedAs(alias string) signalWhere[Q] {
func buildSignalWhere[Q psql.Filterable](cols signalColumns) signalWhere[Q] {
return signalWhere[Q]{
Addressed: psql.WhereNull[Q, time.Time](cols.Addressed),
Addressor: psql.WhereNull[Q, int32](cols.Addressor),
Created: psql.Where[Q, time.Time](cols.Created),
Creator: psql.Where[Q, int32](cols.Creator),
ID: psql.Where[Q, int32](cols.ID),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
Species: psql.WhereNull[Q, enums.Mosquitospecies](cols.Species),
Title: psql.Where[Q, string](cols.Title),
Type: psql.Where[Q, enums.Signaltype](cols.Type),
SiteID: psql.WhereNull[Q, int32](cols.SiteID),
Location: psql.Where[Q, string](cols.Location),
LocationType: psql.WhereNull[Q, string](cols.LocationType),
Addressed: psql.WhereNull[Q, time.Time](cols.Addressed),
Addressor: psql.WhereNull[Q, int32](cols.Addressor),
Created: psql.Where[Q, time.Time](cols.Created),
Creator: psql.Where[Q, int32](cols.Creator),
ID: psql.Where[Q, int32](cols.ID),
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
Species: psql.WhereNull[Q, enums.Mosquitospecies](cols.Species),
Type: psql.Where[Q, enums.Signaltype](cols.Type),
SiteID: psql.WhereNull[Q, int32](cols.SiteID),
Location: psql.Where[Q, string](cols.Location),
LocationType: psql.WhereNull[Q, string](cols.LocationType),
FeaturePoolFeatureID: psql.WhereNull[Q, int32](cols.FeaturePoolFeatureID),
ReportID: psql.WhereNull[Q, int32](cols.ReportID),
}
}
@ -938,6 +1109,18 @@ func (o *Signal) Preload(name string, retrieved any) error {
rel.R.CreatorSignals = SignalSlice{o}
}
return nil
case "FeaturePoolFeatureFeaturePool":
rel, ok := retrieved.(*FeaturePool)
if !ok {
return fmt.Errorf("signal cannot load %T as %q", retrieved, name)
}
o.R.FeaturePoolFeatureFeaturePool = rel
if rel != nil {
rel.R.FeaturePoolFeatureSignals = SignalSlice{o}
}
return nil
case "Organization":
rel, ok := retrieved.(*Organization)
if !ok {
@ -946,6 +1129,18 @@ func (o *Signal) Preload(name string, retrieved any) error {
o.R.Organization = rel
if rel != nil {
rel.R.Signals = SignalSlice{o}
}
return nil
case "Report":
rel, ok := retrieved.(*PublicreportReport)
if !ok {
return fmt.Errorf("signal cannot load %T as %q", retrieved, name)
}
o.R.Report = rel
if rel != nil {
rel.R.Signals = SignalSlice{o}
}
@ -968,10 +1163,12 @@ func (o *Signal) Preload(name string, retrieved any) error {
}
type signalPreloader struct {
AddressorUser func(...psql.PreloadOption) psql.Preloader
CreatorUser func(...psql.PreloadOption) psql.Preloader
Organization func(...psql.PreloadOption) psql.Preloader
Site func(...psql.PreloadOption) psql.Preloader
AddressorUser func(...psql.PreloadOption) psql.Preloader
CreatorUser func(...psql.PreloadOption) psql.Preloader
FeaturePoolFeatureFeaturePool func(...psql.PreloadOption) psql.Preloader
Organization func(...psql.PreloadOption) psql.Preloader
Report func(...psql.PreloadOption) psql.Preloader
Site func(...psql.PreloadOption) psql.Preloader
}
func buildSignalPreloader() signalPreloader {
@ -1002,6 +1199,19 @@ func buildSignalPreloader() signalPreloader {
},
}, Users.Columns.Names(), opts...)
},
FeaturePoolFeatureFeaturePool: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*FeaturePool, FeaturePoolSlice](psql.PreloadRel{
Name: "FeaturePoolFeatureFeaturePool",
Sides: []psql.PreloadSide{
{
From: Signals,
To: FeaturePools,
FromColumns: []string{"feature_pool_feature_id"},
ToColumns: []string{"feature_id"},
},
},
}, FeaturePools.Columns.Names(), opts...)
},
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
Name: "Organization",
@ -1015,6 +1225,19 @@ func buildSignalPreloader() signalPreloader {
},
}, Organizations.Columns.Names(), opts...)
},
Report: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*PublicreportReport, PublicreportReportSlice](psql.PreloadRel{
Name: "Report",
Sides: []psql.PreloadSide{
{
From: Signals,
To: PublicreportReports,
FromColumns: []string{"report_id"},
ToColumns: []string{"id"},
},
},
}, PublicreportReports.Columns.Names(), opts...)
},
Site: func(opts ...psql.PreloadOption) psql.Preloader {
return psql.Preload[*Site, SiteSlice](psql.PreloadRel{
Name: "Site",
@ -1032,10 +1255,12 @@ func buildSignalPreloader() signalPreloader {
}
type signalThenLoader[Q orm.Loadable] struct {
AddressorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
CreatorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Site func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
AddressorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
CreatorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
FeaturePoolFeatureFeaturePool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Report func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
Site func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
}
func buildSignalThenLoader[Q orm.Loadable]() signalThenLoader[Q] {
@ -1045,9 +1270,15 @@ func buildSignalThenLoader[Q orm.Loadable]() signalThenLoader[Q] {
type CreatorUserLoadInterface interface {
LoadCreatorUser(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type FeaturePoolFeatureFeaturePoolLoadInterface interface {
LoadFeaturePoolFeatureFeaturePool(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type OrganizationLoadInterface interface {
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type ReportLoadInterface interface {
LoadReport(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
type SiteLoadInterface interface {
LoadSite(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
}
@ -1065,12 +1296,24 @@ func buildSignalThenLoader[Q orm.Loadable]() signalThenLoader[Q] {
return retrieved.LoadCreatorUser(ctx, exec, mods...)
},
),
FeaturePoolFeatureFeaturePool: thenLoadBuilder[Q](
"FeaturePoolFeatureFeaturePool",
func(ctx context.Context, exec bob.Executor, retrieved FeaturePoolFeatureFeaturePoolLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadFeaturePoolFeatureFeaturePool(ctx, exec, mods...)
},
),
Organization: thenLoadBuilder[Q](
"Organization",
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadOrganization(ctx, exec, mods...)
},
),
Report: thenLoadBuilder[Q](
"Report",
func(ctx context.Context, exec bob.Executor, retrieved ReportLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
return retrieved.LoadReport(ctx, exec, mods...)
},
),
Site: thenLoadBuilder[Q](
"Site",
func(ctx context.Context, exec bob.Executor, retrieved SiteLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
@ -1187,6 +1430,61 @@ func (os SignalSlice) LoadCreatorUser(ctx context.Context, exec bob.Executor, mo
return nil
}
// LoadFeaturePoolFeatureFeaturePool loads the signal's FeaturePoolFeatureFeaturePool into the .R struct
func (o *Signal) LoadFeaturePoolFeatureFeaturePool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
o.R.FeaturePoolFeatureFeaturePool = nil
related, err := o.FeaturePoolFeatureFeaturePool(mods...).One(ctx, exec)
if err != nil {
return err
}
related.R.FeaturePoolFeatureSignals = SignalSlice{o}
o.R.FeaturePoolFeatureFeaturePool = related
return nil
}
// LoadFeaturePoolFeatureFeaturePool loads the signal's FeaturePoolFeatureFeaturePool into the .R struct
func (os SignalSlice) LoadFeaturePoolFeatureFeaturePool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
featurePools, err := os.FeaturePoolFeatureFeaturePool(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, o := range os {
if o == nil {
continue
}
for _, rel := range featurePools {
if !o.FeaturePoolFeatureID.IsValue() {
continue
}
if !(o.FeaturePoolFeatureID.IsValue() && o.FeaturePoolFeatureID.MustGet() == rel.FeatureID) {
continue
}
rel.R.FeaturePoolFeatureSignals = append(rel.R.FeaturePoolFeatureSignals, o)
o.R.FeaturePoolFeatureFeaturePool = rel
break
}
}
return nil
}
// LoadOrganization loads the signal's Organization into the .R struct
func (o *Signal) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
@ -1239,6 +1537,61 @@ func (os SignalSlice) LoadOrganization(ctx context.Context, exec bob.Executor, m
return nil
}
// LoadReport loads the signal's Report into the .R struct
func (o *Signal) LoadReport(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {
return nil
}
// Reset the relationship
o.R.Report = nil
related, err := o.Report(mods...).One(ctx, exec)
if err != nil {
return err
}
related.R.Signals = SignalSlice{o}
o.R.Report = related
return nil
}
// LoadReport loads the signal's Report into the .R struct
func (os SignalSlice) LoadReport(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if len(os) == 0 {
return nil
}
publicreportReports, err := os.Report(mods...).All(ctx, exec)
if err != nil {
return err
}
for _, o := range os {
if o == nil {
continue
}
for _, rel := range publicreportReports {
if !o.ReportID.IsValue() {
continue
}
if !(o.ReportID.IsValue() && o.ReportID.MustGet() == rel.ID) {
continue
}
rel.R.Signals = append(rel.R.Signals, o)
o.R.Report = rel
break
}
}
return nil
}
// LoadSite loads the signal's Site into the .R struct
func (o *Signal) LoadSite(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
if o == nil {