Add new communication table
It allows us to track when communication tasks are complete, and information about how they were completed, separate from the entries that created the tasks in the first place (reports, emails, texts)
This commit is contained in:
parent
6a47302192
commit
a82b2b8cb8
10 changed files with 4258 additions and 42 deletions
17
db/dberrors/communication.bob.go
Normal file
17
db/dberrors/communication.bob.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
var CommunicationErrors = &communicationErrors{
|
||||
ErrUniqueCommunicationPkey: &UniqueConstraintError{
|
||||
schema: "",
|
||||
table: "communication",
|
||||
columns: []string{"id"},
|
||||
s: "communication_pkey",
|
||||
},
|
||||
}
|
||||
|
||||
type communicationErrors struct {
|
||||
ErrUniqueCommunicationPkey *UniqueConstraintError
|
||||
}
|
||||
327
db/dbinfo/communication.bob.go
Normal file
327
db/dbinfo/communication.bob.go
Normal file
|
|
@ -0,0 +1,327 @@
|
|||
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dbinfo
|
||||
|
||||
import "github.com/aarondl/opt/null"
|
||||
|
||||
var Communications = Table[
|
||||
communicationColumns,
|
||||
communicationIndexes,
|
||||
communicationForeignKeys,
|
||||
communicationUniques,
|
||||
communicationChecks,
|
||||
]{
|
||||
Schema: "",
|
||||
Name: "communication",
|
||||
Columns: communicationColumns{
|
||||
Closed: column{
|
||||
Name: "closed",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ClosedBy: column{
|
||||
Name: "closed_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Created: column{
|
||||
Name: "created",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ID: column{
|
||||
Name: "id",
|
||||
DBType: "integer",
|
||||
Default: "nextval('communication_id_seq'::regclass)",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Invalidated: column{
|
||||
Name: "invalidated",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
InvalidatedBy: column{
|
||||
Name: "invalidated_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
Opened: column{
|
||||
Name: "opened",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
OpenedBy: column{
|
||||
Name: "opened_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ResponseEmailLogID: column{
|
||||
Name: "response_email_log_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ResponseTextLogID: column{
|
||||
Name: "response_text_log_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPending: column{
|
||||
Name: "set_pending",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPendingBy: column{
|
||||
Name: "set_pending_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SourceEmailLogID: column{
|
||||
Name: "source_email_log_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SourceReportID: column{
|
||||
Name: "source_report_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SourceTextLogID: column{
|
||||
Name: "source_text_log_id",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: communicationIndexes{
|
||||
CommunicationPkey: index{
|
||||
Type: "btree",
|
||||
Name: "communication_pkey",
|
||||
Columns: []indexColumn{
|
||||
{
|
||||
Name: "id",
|
||||
Desc: null.FromCond(false, true),
|
||||
IsExpression: false,
|
||||
},
|
||||
},
|
||||
Unique: true,
|
||||
Comment: "",
|
||||
NullsFirst: []bool{false},
|
||||
NullsDistinct: false,
|
||||
Where: "",
|
||||
Include: []string{},
|
||||
},
|
||||
},
|
||||
PrimaryKey: &constraint{
|
||||
Name: "communication_pkey",
|
||||
Columns: []string{"id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignKeys: communicationForeignKeys{
|
||||
CommunicationCommunicationClosedByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_closed_by_fkey",
|
||||
Columns: []string{"closed_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationInvalidatedByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_invalidated_by_fkey",
|
||||
Columns: []string{"invalidated_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationOpenedByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_opened_by_fkey",
|
||||
Columns: []string{"opened_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationResponseEmailLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_response_email_log_id_fkey",
|
||||
Columns: []string{"response_email_log_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "comms.email_log",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationResponseTextLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_response_text_log_id_fkey",
|
||||
Columns: []string{"response_text_log_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "comms.text_log",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSetPendingByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_set_pending_by_fkey",
|
||||
Columns: []string{"set_pending_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSourceEmailLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_source_email_log_id_fkey",
|
||||
Columns: []string{"source_email_log_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "comms.email_log",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSourceReportIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_source_report_id_fkey",
|
||||
Columns: []string{"source_report_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "publicreport.report",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSourceTextLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_source_text_log_id_fkey",
|
||||
Columns: []string{"source_text_log_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "comms.text_log",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
|
||||
Comment: "",
|
||||
}
|
||||
|
||||
type communicationColumns struct {
|
||||
Closed column
|
||||
ClosedBy column
|
||||
Created column
|
||||
ID column
|
||||
Invalidated column
|
||||
InvalidatedBy column
|
||||
Opened column
|
||||
OpenedBy column
|
||||
ResponseEmailLogID column
|
||||
ResponseTextLogID column
|
||||
SetPending column
|
||||
SetPendingBy column
|
||||
SourceEmailLogID column
|
||||
SourceReportID column
|
||||
SourceTextLogID column
|
||||
}
|
||||
|
||||
func (c communicationColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.Closed, c.ClosedBy, c.Created, c.ID, c.Invalidated, c.InvalidatedBy, c.Opened, c.OpenedBy, c.ResponseEmailLogID, c.ResponseTextLogID, c.SetPending, c.SetPendingBy, c.SourceEmailLogID, c.SourceReportID, c.SourceTextLogID,
|
||||
}
|
||||
}
|
||||
|
||||
type communicationIndexes struct {
|
||||
CommunicationPkey index
|
||||
}
|
||||
|
||||
func (i communicationIndexes) AsSlice() []index {
|
||||
return []index{
|
||||
i.CommunicationPkey,
|
||||
}
|
||||
}
|
||||
|
||||
type communicationForeignKeys struct {
|
||||
CommunicationCommunicationClosedByFkey foreignKey
|
||||
CommunicationCommunicationInvalidatedByFkey foreignKey
|
||||
CommunicationCommunicationOpenedByFkey foreignKey
|
||||
CommunicationCommunicationResponseEmailLogIDFkey foreignKey
|
||||
CommunicationCommunicationResponseTextLogIDFkey foreignKey
|
||||
CommunicationCommunicationSetPendingByFkey foreignKey
|
||||
CommunicationCommunicationSourceEmailLogIDFkey foreignKey
|
||||
CommunicationCommunicationSourceReportIDFkey foreignKey
|
||||
CommunicationCommunicationSourceTextLogIDFkey foreignKey
|
||||
}
|
||||
|
||||
func (f communicationForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{
|
||||
f.CommunicationCommunicationClosedByFkey, f.CommunicationCommunicationInvalidatedByFkey, f.CommunicationCommunicationOpenedByFkey, f.CommunicationCommunicationResponseEmailLogIDFkey, f.CommunicationCommunicationResponseTextLogIDFkey, f.CommunicationCommunicationSetPendingByFkey, f.CommunicationCommunicationSourceEmailLogIDFkey, f.CommunicationCommunicationSourceReportIDFkey, f.CommunicationCommunicationSourceTextLogIDFkey,
|
||||
}
|
||||
}
|
||||
|
||||
type communicationUniques struct{}
|
||||
|
||||
func (u communicationUniques) AsSlice() []constraint {
|
||||
return []constraint{}
|
||||
}
|
||||
|
||||
type communicationChecks struct{}
|
||||
|
||||
func (c communicationChecks) AsSlice() []check {
|
||||
return []check{}
|
||||
}
|
||||
21
db/migrations/00147_communication.sql
Normal file
21
db/migrations/00147_communication.sql
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- +goose Up
|
||||
CREATE TABLE communication (
|
||||
closed TIMESTAMP WITHOUT TIME ZONE,
|
||||
closed_by INTEGER REFERENCES user_(id),
|
||||
created TIMESTAMP WITHOUT TIME ZONE NOT NULL,
|
||||
id SERIAL,
|
||||
invalidated TIMESTAMP WITHOUT TIME ZONE,
|
||||
invalidated_by INTEGER REFERENCES user_(id),
|
||||
opened TIMESTAMP WITHOUT TIME ZONE,
|
||||
opened_by INTEGER REFERENCES user_(id),
|
||||
response_email_log_id INTEGER REFERENCES comms.email_log(id),
|
||||
response_text_log_id INTEGER REFERENCES comms.text_log(id),
|
||||
set_pending TIMESTAMP WITHOUT TIME ZONE,
|
||||
set_pending_by INTEGER REFERENCES user_(id),
|
||||
source_email_log_id INTEGER REFERENCES comms.email_log(id),
|
||||
source_report_id INTEGER REFERENCES publicreport.report(id),
|
||||
source_text_log_id INTEGER REFERENCES comms.text_log(id),
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
-- +goose Down
|
||||
DROP TABLE communication;
|
||||
|
|
@ -35,6 +35,7 @@ type preloaders struct {
|
|||
CommsPhone commsPhonePreloader
|
||||
CommsTextJob commsTextJobPreloader
|
||||
CommsTextLog commsTextLogPreloader
|
||||
Communication communicationPreloader
|
||||
ComplianceReportRequest complianceReportRequestPreloader
|
||||
ComplianceReportRequestMailer complianceReportRequestMailerPreloader
|
||||
DistrictSubscriptionEmail districtSubscriptionEmailPreloader
|
||||
|
|
@ -138,6 +139,7 @@ func getPreloaders() preloaders {
|
|||
CommsPhone: buildCommsPhonePreloader(),
|
||||
CommsTextJob: buildCommsTextJobPreloader(),
|
||||
CommsTextLog: buildCommsTextLogPreloader(),
|
||||
Communication: buildCommunicationPreloader(),
|
||||
ComplianceReportRequest: buildComplianceReportRequestPreloader(),
|
||||
ComplianceReportRequestMailer: buildComplianceReportRequestMailerPreloader(),
|
||||
DistrictSubscriptionEmail: buildDistrictSubscriptionEmailPreloader(),
|
||||
|
|
@ -247,6 +249,7 @@ type thenLoaders[Q orm.Loadable] struct {
|
|||
CommsPhone commsPhoneThenLoader[Q]
|
||||
CommsTextJob commsTextJobThenLoader[Q]
|
||||
CommsTextLog commsTextLogThenLoader[Q]
|
||||
Communication communicationThenLoader[Q]
|
||||
ComplianceReportRequest complianceReportRequestThenLoader[Q]
|
||||
ComplianceReportRequestMailer complianceReportRequestMailerThenLoader[Q]
|
||||
DistrictSubscriptionEmail districtSubscriptionEmailThenLoader[Q]
|
||||
|
|
@ -350,6 +353,7 @@ func getThenLoaders[Q orm.Loadable]() thenLoaders[Q] {
|
|||
CommsPhone: buildCommsPhoneThenLoader[Q](),
|
||||
CommsTextJob: buildCommsTextJobThenLoader[Q](),
|
||||
CommsTextLog: buildCommsTextLogThenLoader[Q](),
|
||||
Communication: buildCommunicationThenLoader[Q](),
|
||||
ComplianceReportRequest: buildComplianceReportRequestThenLoader[Q](),
|
||||
ComplianceReportRequestMailer: buildComplianceReportRequestMailerThenLoader[Q](),
|
||||
DistrictSubscriptionEmail: buildDistrictSubscriptionEmailThenLoader[Q](),
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
CommsPhones commsPhoneWhere[Q]
|
||||
CommsTextJobs commsTextJobWhere[Q]
|
||||
CommsTextLogs commsTextLogWhere[Q]
|
||||
Communications communicationWhere[Q]
|
||||
ComplianceReportRequests complianceReportRequestWhere[Q]
|
||||
ComplianceReportRequestMailers complianceReportRequestMailerWhere[Q]
|
||||
DistrictSubscriptionEmails districtSubscriptionEmailWhere[Q]
|
||||
|
|
@ -146,6 +147,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
CommsPhones commsPhoneWhere[Q]
|
||||
CommsTextJobs commsTextJobWhere[Q]
|
||||
CommsTextLogs commsTextLogWhere[Q]
|
||||
Communications communicationWhere[Q]
|
||||
ComplianceReportRequests complianceReportRequestWhere[Q]
|
||||
ComplianceReportRequestMailers complianceReportRequestMailerWhere[Q]
|
||||
DistrictSubscriptionEmails districtSubscriptionEmailWhere[Q]
|
||||
|
|
@ -256,6 +258,7 @@ func Where[Q psql.Filterable]() struct {
|
|||
CommsPhones: buildCommsPhoneWhere[Q](CommsPhones.Columns),
|
||||
CommsTextJobs: buildCommsTextJobWhere[Q](CommsTextJobs.Columns),
|
||||
CommsTextLogs: buildCommsTextLogWhere[Q](CommsTextLogs.Columns),
|
||||
Communications: buildCommunicationWhere[Q](Communications.Columns),
|
||||
ComplianceReportRequests: buildComplianceReportRequestWhere[Q](ComplianceReportRequests.Columns),
|
||||
ComplianceReportRequestMailers: buildComplianceReportRequestMailerWhere[Q](ComplianceReportRequestMailers.Columns),
|
||||
DistrictSubscriptionEmails: buildDistrictSubscriptionEmailWhere[Q](DistrictSubscriptionEmails.Columns),
|
||||
|
|
|
|||
|
|
@ -53,9 +53,11 @@ type CommsEmailLogsQuery = *psql.ViewQuery[*CommsEmailLog, CommsEmailLogSlice]
|
|||
|
||||
// commsEmailLogR is where relationships are stored.
|
||||
type commsEmailLogR struct {
|
||||
DestinationEmailContact *CommsEmailContact // comms.email_log.email_log_destination_fkey
|
||||
TemplateEmailTemplate *CommsEmailTemplate // comms.email_log.email_log_template_id_fkey
|
||||
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_email_log_id_fkey
|
||||
DestinationEmailContact *CommsEmailContact // comms.email_log.email_log_destination_fkey
|
||||
TemplateEmailTemplate *CommsEmailTemplate // comms.email_log.email_log_template_id_fkey
|
||||
ResponseEmailLogCommunications CommunicationSlice // communication.communication_response_email_log_id_fkey
|
||||
SourceEmailLogCommunications CommunicationSlice // communication.communication_source_email_log_id_fkey
|
||||
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_email_log_id_fkey
|
||||
}
|
||||
|
||||
func buildCommsEmailLogColumns(alias string) commsEmailLogColumns {
|
||||
|
|
@ -628,6 +630,54 @@ func (os CommsEmailLogSlice) TemplateEmailTemplate(mods ...bob.Mod[*dialect.Sele
|
|||
)...)
|
||||
}
|
||||
|
||||
// ResponseEmailLogCommunications starts a query for related objects on communication
|
||||
func (o *CommsEmailLog) ResponseEmailLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.ResponseEmailLogID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os CommsEmailLogSlice) ResponseEmailLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.ResponseEmailLogID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// SourceEmailLogCommunications starts a query for related objects on communication
|
||||
func (o *CommsEmailLog) SourceEmailLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SourceEmailLogID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os CommsEmailLogSlice) SourceEmailLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.SourceEmailLogID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// ReportLogs starts a query for related objects on publicreport.report_log
|
||||
func (o *CommsEmailLog) ReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
||||
return PublicreportReportLogs.Query(append(mods,
|
||||
|
|
@ -748,6 +798,142 @@ func (commsEmailLog0 *CommsEmailLog) AttachTemplateEmailTemplate(ctx context.Con
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertCommsEmailLogResponseEmailLogCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, commsEmailLog0 *CommsEmailLog) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].ResponseEmailLogID = omitnull.From(commsEmailLog0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertCommsEmailLogResponseEmailLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachCommsEmailLogResponseEmailLogCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, commsEmailLog0 *CommsEmailLog) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
ResponseEmailLogID: omitnull.From(commsEmailLog0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachCommsEmailLogResponseEmailLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (commsEmailLog0 *CommsEmailLog) InsertResponseEmailLogCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertCommsEmailLogResponseEmailLogCommunications0(ctx, exec, related, commsEmailLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsEmailLog0.R.ResponseEmailLogCommunications = append(commsEmailLog0.R.ResponseEmailLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.ResponseEmailLogEmailLog = commsEmailLog0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (commsEmailLog0 *CommsEmailLog) AttachResponseEmailLogCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachCommsEmailLogResponseEmailLogCommunications0(ctx, exec, len(related), communications1, commsEmailLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsEmailLog0.R.ResponseEmailLogCommunications = append(commsEmailLog0.R.ResponseEmailLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ResponseEmailLogEmailLog = commsEmailLog0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertCommsEmailLogSourceEmailLogCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, commsEmailLog0 *CommsEmailLog) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SourceEmailLogID = omitnull.From(commsEmailLog0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertCommsEmailLogSourceEmailLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachCommsEmailLogSourceEmailLogCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, commsEmailLog0 *CommsEmailLog) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SourceEmailLogID: omitnull.From(commsEmailLog0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachCommsEmailLogSourceEmailLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (commsEmailLog0 *CommsEmailLog) InsertSourceEmailLogCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertCommsEmailLogSourceEmailLogCommunications0(ctx, exec, related, commsEmailLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsEmailLog0.R.SourceEmailLogCommunications = append(commsEmailLog0.R.SourceEmailLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SourceEmailLogEmailLog = commsEmailLog0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (commsEmailLog0 *CommsEmailLog) AttachSourceEmailLogCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachCommsEmailLogSourceEmailLogCommunications0(ctx, exec, len(related), communications1, commsEmailLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsEmailLog0.R.SourceEmailLogCommunications = append(commsEmailLog0.R.SourceEmailLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceEmailLogEmailLog = commsEmailLog0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertCommsEmailLogReportLogs0(ctx context.Context, exec bob.Executor, publicreportReportLogs1 []*PublicreportReportLogSetter, commsEmailLog0 *CommsEmailLog) (PublicreportReportLogSlice, error) {
|
||||
for i := range publicreportReportLogs1 {
|
||||
publicreportReportLogs1[i].EmailLogID = omitnull.From(commsEmailLog0.ID)
|
||||
|
|
@ -880,6 +1066,34 @@ func (o *CommsEmailLog) Preload(name string, retrieved any) error {
|
|||
rel.R.TemplateEmailLogs = CommsEmailLogSlice{o}
|
||||
}
|
||||
return nil
|
||||
case "ResponseEmailLogCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("commsEmailLog cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.ResponseEmailLogCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.ResponseEmailLogEmailLog = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "SourceEmailLogCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("commsEmailLog cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SourceEmailLogCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SourceEmailLogEmailLog = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "ReportLogs":
|
||||
rels, ok := retrieved.(PublicreportReportLogSlice)
|
||||
if !ok {
|
||||
|
|
@ -936,9 +1150,11 @@ func buildCommsEmailLogPreloader() commsEmailLogPreloader {
|
|||
}
|
||||
|
||||
type commsEmailLogThenLoader[Q orm.Loadable] struct {
|
||||
DestinationEmailContact func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
TemplateEmailTemplate func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DestinationEmailContact func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
TemplateEmailTemplate func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ResponseEmailLogCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SourceEmailLogCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildCommsEmailLogThenLoader[Q orm.Loadable]() commsEmailLogThenLoader[Q] {
|
||||
|
|
@ -948,6 +1164,12 @@ func buildCommsEmailLogThenLoader[Q orm.Loadable]() commsEmailLogThenLoader[Q] {
|
|||
type TemplateEmailTemplateLoadInterface interface {
|
||||
LoadTemplateEmailTemplate(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ResponseEmailLogCommunicationsLoadInterface interface {
|
||||
LoadResponseEmailLogCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SourceEmailLogCommunicationsLoadInterface interface {
|
||||
LoadSourceEmailLogCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ReportLogsLoadInterface interface {
|
||||
LoadReportLogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -965,6 +1187,18 @@ func buildCommsEmailLogThenLoader[Q orm.Loadable]() commsEmailLogThenLoader[Q] {
|
|||
return retrieved.LoadTemplateEmailTemplate(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ResponseEmailLogCommunications: thenLoadBuilder[Q](
|
||||
"ResponseEmailLogCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ResponseEmailLogCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadResponseEmailLogCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SourceEmailLogCommunications: thenLoadBuilder[Q](
|
||||
"SourceEmailLogCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SourceEmailLogCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSourceEmailLogCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ReportLogs: thenLoadBuilder[Q](
|
||||
"ReportLogs",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ReportLogsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -1078,6 +1312,134 @@ func (os CommsEmailLogSlice) LoadTemplateEmailTemplate(ctx context.Context, exec
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadResponseEmailLogCommunications loads the commsEmailLog's ResponseEmailLogCommunications into the .R struct
|
||||
func (o *CommsEmailLog) LoadResponseEmailLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.ResponseEmailLogCommunications = nil
|
||||
|
||||
related, err := o.ResponseEmailLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ResponseEmailLogEmailLog = o
|
||||
}
|
||||
|
||||
o.R.ResponseEmailLogCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadResponseEmailLogCommunications loads the commsEmailLog's ResponseEmailLogCommunications into the .R struct
|
||||
func (os CommsEmailLogSlice) LoadResponseEmailLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.ResponseEmailLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.ResponseEmailLogCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.ResponseEmailLogID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.ResponseEmailLogID.IsValue() && o.ID == rel.ResponseEmailLogID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.ResponseEmailLogEmailLog = o
|
||||
|
||||
o.R.ResponseEmailLogCommunications = append(o.R.ResponseEmailLogCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceEmailLogCommunications loads the commsEmailLog's SourceEmailLogCommunications into the .R struct
|
||||
func (o *CommsEmailLog) LoadSourceEmailLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SourceEmailLogCommunications = nil
|
||||
|
||||
related, err := o.SourceEmailLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceEmailLogEmailLog = o
|
||||
}
|
||||
|
||||
o.R.SourceEmailLogCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceEmailLogCommunications loads the commsEmailLog's SourceEmailLogCommunications into the .R struct
|
||||
func (os CommsEmailLogSlice) LoadSourceEmailLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SourceEmailLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SourceEmailLogCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SourceEmailLogID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SourceEmailLogID.IsValue() && o.ID == rel.SourceEmailLogID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SourceEmailLogEmailLog = o
|
||||
|
||||
o.R.SourceEmailLogCommunications = append(o.R.SourceEmailLogCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadReportLogs loads the commsEmailLog's ReportLogs into the .R struct
|
||||
func (o *CommsEmailLog) LoadReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
|
|
@ -52,10 +52,12 @@ type CommsTextLogsQuery = *psql.ViewQuery[*CommsTextLog, CommsTextLogSlice]
|
|||
|
||||
// commsTextLogR is where relationships are stored.
|
||||
type commsTextLogR struct {
|
||||
DestinationPhone *CommsPhone // comms.text_log.text_log_destination_fkey
|
||||
SourcePhone *CommsPhone // comms.text_log.text_log_source_fkey
|
||||
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_text_log_id_fkey
|
||||
ReportTexts ReportTextSlice // report_text.report_text_text_log_id_fkey
|
||||
DestinationPhone *CommsPhone // comms.text_log.text_log_destination_fkey
|
||||
SourcePhone *CommsPhone // comms.text_log.text_log_source_fkey
|
||||
ResponseTextLogCommunications CommunicationSlice // communication.communication_response_text_log_id_fkey
|
||||
SourceTextLogCommunications CommunicationSlice // communication.communication_source_text_log_id_fkey
|
||||
ReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_text_log_id_fkey
|
||||
ReportTexts ReportTextSlice // report_text.report_text_text_log_id_fkey
|
||||
}
|
||||
|
||||
func buildCommsTextLogColumns(alias string) commsTextLogColumns {
|
||||
|
|
@ -606,6 +608,54 @@ func (os CommsTextLogSlice) SourcePhone(mods ...bob.Mod[*dialect.SelectQuery]) C
|
|||
)...)
|
||||
}
|
||||
|
||||
// ResponseTextLogCommunications starts a query for related objects on communication
|
||||
func (o *CommsTextLog) ResponseTextLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.ResponseTextLogID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os CommsTextLogSlice) ResponseTextLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.ResponseTextLogID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// SourceTextLogCommunications starts a query for related objects on communication
|
||||
func (o *CommsTextLog) SourceTextLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SourceTextLogID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os CommsTextLogSlice) SourceTextLogCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.SourceTextLogID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// ReportLogs starts a query for related objects on publicreport.report_log
|
||||
func (o *CommsTextLog) ReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
||||
return PublicreportReportLogs.Query(append(mods,
|
||||
|
|
@ -750,6 +800,142 @@ func (commsTextLog0 *CommsTextLog) AttachSourcePhone(ctx context.Context, exec b
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertCommsTextLogResponseTextLogCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, commsTextLog0 *CommsTextLog) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].ResponseTextLogID = omitnull.From(commsTextLog0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertCommsTextLogResponseTextLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachCommsTextLogResponseTextLogCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, commsTextLog0 *CommsTextLog) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
ResponseTextLogID: omitnull.From(commsTextLog0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachCommsTextLogResponseTextLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (commsTextLog0 *CommsTextLog) InsertResponseTextLogCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertCommsTextLogResponseTextLogCommunications0(ctx, exec, related, commsTextLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsTextLog0.R.ResponseTextLogCommunications = append(commsTextLog0.R.ResponseTextLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.ResponseTextLogTextLog = commsTextLog0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (commsTextLog0 *CommsTextLog) AttachResponseTextLogCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachCommsTextLogResponseTextLogCommunications0(ctx, exec, len(related), communications1, commsTextLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsTextLog0.R.ResponseTextLogCommunications = append(commsTextLog0.R.ResponseTextLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ResponseTextLogTextLog = commsTextLog0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertCommsTextLogSourceTextLogCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, commsTextLog0 *CommsTextLog) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SourceTextLogID = omitnull.From(commsTextLog0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertCommsTextLogSourceTextLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachCommsTextLogSourceTextLogCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, commsTextLog0 *CommsTextLog) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SourceTextLogID: omitnull.From(commsTextLog0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachCommsTextLogSourceTextLogCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (commsTextLog0 *CommsTextLog) InsertSourceTextLogCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertCommsTextLogSourceTextLogCommunications0(ctx, exec, related, commsTextLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsTextLog0.R.SourceTextLogCommunications = append(commsTextLog0.R.SourceTextLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SourceTextLogTextLog = commsTextLog0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (commsTextLog0 *CommsTextLog) AttachSourceTextLogCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachCommsTextLogSourceTextLogCommunications0(ctx, exec, len(related), communications1, commsTextLog0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commsTextLog0.R.SourceTextLogCommunications = append(commsTextLog0.R.SourceTextLogCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceTextLogTextLog = commsTextLog0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertCommsTextLogReportLogs0(ctx context.Context, exec bob.Executor, publicreportReportLogs1 []*PublicreportReportLogSetter, commsTextLog0 *CommsTextLog) (PublicreportReportLogSlice, error) {
|
||||
for i := range publicreportReportLogs1 {
|
||||
publicreportReportLogs1[i].TextLogID = omitnull.From(commsTextLog0.ID)
|
||||
|
|
@ -948,6 +1134,34 @@ func (o *CommsTextLog) Preload(name string, retrieved any) error {
|
|||
rel.R.SourceTextLogs = CommsTextLogSlice{o}
|
||||
}
|
||||
return nil
|
||||
case "ResponseTextLogCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("commsTextLog cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.ResponseTextLogCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.ResponseTextLogTextLog = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "SourceTextLogCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("commsTextLog cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SourceTextLogCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SourceTextLogTextLog = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "ReportLogs":
|
||||
rels, ok := retrieved.(PublicreportReportLogSlice)
|
||||
if !ok {
|
||||
|
|
@ -1018,10 +1232,12 @@ func buildCommsTextLogPreloader() commsTextLogPreloader {
|
|||
}
|
||||
|
||||
type commsTextLogThenLoader[Q orm.Loadable] struct {
|
||||
DestinationPhone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SourcePhone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DestinationPhone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SourcePhone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ResponseTextLogCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SourceTextLogCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildCommsTextLogThenLoader[Q orm.Loadable]() commsTextLogThenLoader[Q] {
|
||||
|
|
@ -1031,6 +1247,12 @@ func buildCommsTextLogThenLoader[Q orm.Loadable]() commsTextLogThenLoader[Q] {
|
|||
type SourcePhoneLoadInterface interface {
|
||||
LoadSourcePhone(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ResponseTextLogCommunicationsLoadInterface interface {
|
||||
LoadResponseTextLogCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SourceTextLogCommunicationsLoadInterface interface {
|
||||
LoadSourceTextLogCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ReportLogsLoadInterface interface {
|
||||
LoadReportLogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -1051,6 +1273,18 @@ func buildCommsTextLogThenLoader[Q orm.Loadable]() commsTextLogThenLoader[Q] {
|
|||
return retrieved.LoadSourcePhone(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ResponseTextLogCommunications: thenLoadBuilder[Q](
|
||||
"ResponseTextLogCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ResponseTextLogCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadResponseTextLogCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SourceTextLogCommunications: thenLoadBuilder[Q](
|
||||
"SourceTextLogCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SourceTextLogCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSourceTextLogCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ReportLogs: thenLoadBuilder[Q](
|
||||
"ReportLogs",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ReportLogsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -1170,6 +1404,134 @@ func (os CommsTextLogSlice) LoadSourcePhone(ctx context.Context, exec bob.Execut
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadResponseTextLogCommunications loads the commsTextLog's ResponseTextLogCommunications into the .R struct
|
||||
func (o *CommsTextLog) LoadResponseTextLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.ResponseTextLogCommunications = nil
|
||||
|
||||
related, err := o.ResponseTextLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ResponseTextLogTextLog = o
|
||||
}
|
||||
|
||||
o.R.ResponseTextLogCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadResponseTextLogCommunications loads the commsTextLog's ResponseTextLogCommunications into the .R struct
|
||||
func (os CommsTextLogSlice) LoadResponseTextLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.ResponseTextLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.ResponseTextLogCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.ResponseTextLogID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.ResponseTextLogID.IsValue() && o.ID == rel.ResponseTextLogID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.ResponseTextLogTextLog = o
|
||||
|
||||
o.R.ResponseTextLogCommunications = append(o.R.ResponseTextLogCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceTextLogCommunications loads the commsTextLog's SourceTextLogCommunications into the .R struct
|
||||
func (o *CommsTextLog) LoadSourceTextLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SourceTextLogCommunications = nil
|
||||
|
||||
related, err := o.SourceTextLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceTextLogTextLog = o
|
||||
}
|
||||
|
||||
o.R.SourceTextLogCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceTextLogCommunications loads the commsTextLog's SourceTextLogCommunications into the .R struct
|
||||
func (os CommsTextLogSlice) LoadSourceTextLogCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SourceTextLogCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SourceTextLogCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SourceTextLogID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SourceTextLogID.IsValue() && o.ID == rel.SourceTextLogID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SourceTextLogTextLog = o
|
||||
|
||||
o.R.SourceTextLogCommunications = append(o.R.SourceTextLogCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadReportLogs loads the commsTextLog's ReportLogs into the .R struct
|
||||
func (o *CommsTextLog) LoadReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
2215
db/models/communication.bob.go
Normal file
2215
db/models/communication.bob.go
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -68,20 +68,21 @@ type PublicreportReportsQuery = *psql.ViewQuery[*PublicreportReport, Publicrepor
|
|||
|
||||
// publicreportReportR is where relationships are stored.
|
||||
type publicreportReportR struct {
|
||||
TextJobs CommsTextJobSlice // comms.text_job.text_job_report_id_fkey
|
||||
Compliance *PublicreportCompliance // publicreport.compliance.compliance_report_id_fkey
|
||||
NotifyEmails PublicreportNotifyEmailSlice // publicreport.notify_email.notify_email_report_id_fkey
|
||||
NotifyPhones PublicreportNotifyPhoneSlice // publicreport.notify_phone.notify_phone_report_id_fkey
|
||||
Nuisance *PublicreportNuisance // publicreport.nuisance.nuisance_report_id_fkey
|
||||
Address *Address // publicreport.report.report_address_id_fkey
|
||||
Client *PublicreportClient // publicreport.report.report_client_uuid_fkey
|
||||
Organization *Organization // publicreport.report.report_organization_id_fkey
|
||||
ReviewerUser *User // publicreport.report.report_reviewer_id_fkey
|
||||
Images PublicreportImageSlice // publicreport.report_image.report_image_image_id_fkeypublicreport.report_image.report_image_report_id_fkey
|
||||
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
|
||||
TextJobs CommsTextJobSlice // comms.text_job.text_job_report_id_fkey
|
||||
SourceReportCommunications CommunicationSlice // communication.communication_source_report_id_fkey
|
||||
Compliance *PublicreportCompliance // publicreport.compliance.compliance_report_id_fkey
|
||||
NotifyEmails PublicreportNotifyEmailSlice // publicreport.notify_email.notify_email_report_id_fkey
|
||||
NotifyPhones PublicreportNotifyPhoneSlice // publicreport.notify_phone.notify_phone_report_id_fkey
|
||||
Nuisance *PublicreportNuisance // publicreport.nuisance.nuisance_report_id_fkey
|
||||
Address *Address // publicreport.report.report_address_id_fkey
|
||||
Client *PublicreportClient // publicreport.report.report_client_uuid_fkey
|
||||
Organization *Organization // publicreport.report.report_organization_id_fkey
|
||||
ReviewerUser *User // publicreport.report.report_reviewer_id_fkey
|
||||
Images PublicreportImageSlice // publicreport.report_image.report_image_image_id_fkeypublicreport.report_image.report_image_report_id_fkey
|
||||
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 {
|
||||
|
|
@ -876,6 +877,30 @@ func (os PublicreportReportSlice) TextJobs(mods ...bob.Mod[*dialect.SelectQuery]
|
|||
)...)
|
||||
}
|
||||
|
||||
// SourceReportCommunications starts a query for related objects on communication
|
||||
func (o *PublicreportReport) SourceReportCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SourceReportID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os PublicreportReportSlice) SourceReportCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.SourceReportID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// Compliance starts a query for related objects on publicreport.compliance
|
||||
func (o *PublicreportReport) Compliance(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportCompliancesQuery {
|
||||
return PublicreportCompliances.Query(append(mods,
|
||||
|
|
@ -1261,6 +1286,74 @@ func (publicreportReport0 *PublicreportReport) AttachTextJobs(ctx context.Contex
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertPublicreportReportSourceReportCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, publicreportReport0 *PublicreportReport) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SourceReportID = omitnull.From(publicreportReport0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertPublicreportReportSourceReportCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachPublicreportReportSourceReportCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, publicreportReport0 *PublicreportReport) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SourceReportID: omitnull.From(publicreportReport0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachPublicreportReportSourceReportCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (publicreportReport0 *PublicreportReport) InsertSourceReportCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertPublicreportReportSourceReportCommunications0(ctx, exec, related, publicreportReport0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportReport0.R.SourceReportCommunications = append(publicreportReport0.R.SourceReportCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SourceReportReport = publicreportReport0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (publicreportReport0 *PublicreportReport) AttachSourceReportCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachPublicreportReportSourceReportCommunications0(ctx, exec, len(related), communications1, publicreportReport0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
publicreportReport0.R.SourceReportCommunications = append(publicreportReport0.R.SourceReportCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceReportReport = publicreportReport0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertPublicreportReportCompliance0(ctx context.Context, exec bob.Executor, publicreportCompliance1 *PublicreportComplianceSetter, publicreportReport0 *PublicreportReport) (*PublicreportCompliance, error) {
|
||||
publicreportCompliance1.ReportID = omit.From(publicreportReport0.ID)
|
||||
|
||||
|
|
@ -2100,6 +2193,20 @@ func (o *PublicreportReport) Preload(name string, retrieved any) error {
|
|||
}
|
||||
}
|
||||
return nil
|
||||
case "SourceReportCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("publicreportReport cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SourceReportCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SourceReportReport = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "Compliance":
|
||||
rel, ok := retrieved.(*PublicreportCompliance)
|
||||
if !ok {
|
||||
|
|
@ -2380,26 +2487,30 @@ func buildPublicreportReportPreloader() publicreportReportPreloader {
|
|||
}
|
||||
|
||||
type publicreportReportThenLoader[Q orm.Loadable] struct {
|
||||
TextJobs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Compliance func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NotifyEmails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NotifyPhones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Nuisance func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Address func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Client func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
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]
|
||||
TextJobs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SourceReportCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Compliance func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NotifyEmails func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NotifyPhones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Nuisance func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Address func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Client func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Images func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
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] {
|
||||
type TextJobsLoadInterface interface {
|
||||
LoadTextJobs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SourceReportCommunicationsLoadInterface interface {
|
||||
LoadSourceReportCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ComplianceLoadInterface interface {
|
||||
LoadCompliance(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -2447,6 +2558,12 @@ func buildPublicreportReportThenLoader[Q orm.Loadable]() publicreportReportThenL
|
|||
return retrieved.LoadTextJobs(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SourceReportCommunications: thenLoadBuilder[Q](
|
||||
"SourceReportCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SourceReportCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSourceReportCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Compliance: thenLoadBuilder[Q](
|
||||
"Compliance",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ComplianceLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -2592,6 +2709,70 @@ func (os PublicreportReportSlice) LoadTextJobs(ctx context.Context, exec bob.Exe
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceReportCommunications loads the publicreportReport's SourceReportCommunications into the .R struct
|
||||
func (o *PublicreportReport) LoadSourceReportCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SourceReportCommunications = nil
|
||||
|
||||
related, err := o.SourceReportCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SourceReportReport = o
|
||||
}
|
||||
|
||||
o.R.SourceReportCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSourceReportCommunications loads the publicreportReport's SourceReportCommunications into the .R struct
|
||||
func (os PublicreportReportSlice) LoadSourceReportCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SourceReportCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SourceReportCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SourceReportID.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SourceReportID.IsValue() && o.ID == rel.SourceReportID.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SourceReportReport = o
|
||||
|
||||
o.R.SourceReportCommunications = append(o.R.SourceReportCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCompliance loads the publicreportReport's Compliance into the .R struct
|
||||
func (o *PublicreportReport) LoadCompliance(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ type userR struct {
|
|||
UserOauthTokens ArcgisOauthTokenSlice // arcgis.oauth_token.oauth_token_user_id_fkey
|
||||
PublicUserUser ArcgisUserSlice // arcgis.user_.user__public_user_id_fkey
|
||||
CreatorTextJobs CommsTextJobSlice // comms.text_job.text_job_creator_id_fkey
|
||||
ClosedByCommunications CommunicationSlice // communication.communication_closed_by_fkey
|
||||
InvalidatedByCommunications CommunicationSlice // communication.communication_invalidated_by_fkey
|
||||
OpenedByCommunications CommunicationSlice // communication.communication_opened_by_fkey
|
||||
SetPendingByCommunications CommunicationSlice // communication.communication_set_pending_by_fkey
|
||||
CreatorComplianceReportRequests ComplianceReportRequestSlice // compliance_report_request.compliance_report_request_creator_fkey
|
||||
CreatorFeatures FeatureSlice // feature.feature_creator_id_fkey
|
||||
CommitterFiles FileuploadFileSlice // fileupload.file.file_committer_fkey
|
||||
|
|
@ -816,6 +820,102 @@ func (os UserSlice) CreatorTextJobs(mods ...bob.Mod[*dialect.SelectQuery]) Comms
|
|||
)...)
|
||||
}
|
||||
|
||||
// ClosedByCommunications starts a query for related objects on communication
|
||||
func (o *User) ClosedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.ClosedBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) ClosedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.ClosedBy).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// InvalidatedByCommunications starts a query for related objects on communication
|
||||
func (o *User) InvalidatedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.InvalidatedBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) InvalidatedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.InvalidatedBy).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// OpenedByCommunications starts a query for related objects on communication
|
||||
func (o *User) OpenedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.OpenedBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) OpenedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.OpenedBy).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// SetPendingByCommunications starts a query for related objects on communication
|
||||
func (o *User) SetPendingByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SetPendingBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) SetPendingByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
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 Communications.Query(append(mods,
|
||||
sm.Where(psql.Group(Communications.Columns.SetPendingBy).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// CreatorComplianceReportRequests starts a query for related objects on compliance_report_request
|
||||
func (o *User) CreatorComplianceReportRequests(mods ...bob.Mod[*dialect.SelectQuery]) ComplianceReportRequestsQuery {
|
||||
return ComplianceReportRequests.Query(append(mods,
|
||||
|
|
@ -1620,6 +1720,278 @@ func (user0 *User) AttachCreatorTextJobs(ctx context.Context, exec bob.Executor,
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertUserClosedByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].ClosedBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserClosedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserClosedByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
ClosedBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserClosedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertClosedByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserClosedByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.ClosedByCommunications = append(user0.R.ClosedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.ClosedByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachClosedByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserClosedByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.ClosedByCommunications = append(user0.R.ClosedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ClosedByUser = user0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertUserInvalidatedByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].InvalidatedBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserInvalidatedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserInvalidatedByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
InvalidatedBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserInvalidatedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertInvalidatedByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserInvalidatedByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.InvalidatedByCommunications = append(user0.R.InvalidatedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.InvalidatedByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachInvalidatedByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserInvalidatedByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.InvalidatedByCommunications = append(user0.R.InvalidatedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.InvalidatedByUser = user0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertUserOpenedByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].OpenedBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserOpenedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserOpenedByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
OpenedBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserOpenedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertOpenedByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserOpenedByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.OpenedByCommunications = append(user0.R.OpenedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.OpenedByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachOpenedByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserOpenedByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.OpenedByCommunications = append(user0.R.OpenedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.OpenedByUser = user0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertUserSetPendingByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SetPendingBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserSetPendingByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserSetPendingByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SetPendingBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserSetPendingByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertSetPendingByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserSetPendingByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPendingByCommunications = append(user0.R.SetPendingByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SetPendingByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachSetPendingByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserSetPendingByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPendingByCommunications = append(user0.R.SetPendingByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPendingByUser = user0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertUserCreatorComplianceReportRequests0(ctx context.Context, exec bob.Executor, complianceReportRequests1 []*ComplianceReportRequestSetter, user0 *User) (ComplianceReportRequestSlice, error) {
|
||||
for i := range complianceReportRequests1 {
|
||||
complianceReportRequests1[i].Creator = omit.From(user0.ID)
|
||||
|
|
@ -3394,6 +3766,62 @@ func (o *User) Preload(name string, retrieved any) error {
|
|||
}
|
||||
}
|
||||
return nil
|
||||
case "ClosedByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.ClosedByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.ClosedByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "InvalidatedByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.InvalidatedByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.InvalidatedByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "OpenedByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.OpenedByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.OpenedByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "SetPendingByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SetPendingByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SetPendingByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "CreatorComplianceReportRequests":
|
||||
rels, ok := retrieved.(ComplianceReportRequestSlice)
|
||||
if !ok {
|
||||
|
|
@ -3773,6 +4201,10 @@ type userThenLoader[Q orm.Loadable] struct {
|
|||
UserOauthTokens func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
PublicUserUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorTextJobs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ClosedByCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
InvalidatedByCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
OpenedByCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SetPendingByCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorComplianceReportRequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorFeatures func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CommitterFiles func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
|
|
@ -3810,6 +4242,18 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
|||
type CreatorTextJobsLoadInterface interface {
|
||||
LoadCreatorTextJobs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type ClosedByCommunicationsLoadInterface interface {
|
||||
LoadClosedByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type InvalidatedByCommunicationsLoadInterface interface {
|
||||
LoadInvalidatedByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type OpenedByCommunicationsLoadInterface interface {
|
||||
LoadOpenedByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SetPendingByCommunicationsLoadInterface interface {
|
||||
LoadSetPendingByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type CreatorComplianceReportRequestsLoadInterface interface {
|
||||
LoadCreatorComplianceReportRequests(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -3905,6 +4349,30 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
|||
return retrieved.LoadCreatorTextJobs(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
ClosedByCommunications: thenLoadBuilder[Q](
|
||||
"ClosedByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved ClosedByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadClosedByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
InvalidatedByCommunications: thenLoadBuilder[Q](
|
||||
"InvalidatedByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved InvalidatedByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadInvalidatedByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
OpenedByCommunications: thenLoadBuilder[Q](
|
||||
"OpenedByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved OpenedByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadOpenedByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SetPendingByCommunications: thenLoadBuilder[Q](
|
||||
"SetPendingByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SetPendingByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSetPendingByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
CreatorComplianceReportRequests: thenLoadBuilder[Q](
|
||||
"CreatorComplianceReportRequests",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved CreatorComplianceReportRequestsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -4244,6 +4712,262 @@ func (os UserSlice) LoadCreatorTextJobs(ctx context.Context, exec bob.Executor,
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadClosedByCommunications loads the user's ClosedByCommunications into the .R struct
|
||||
func (o *User) LoadClosedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.ClosedByCommunications = nil
|
||||
|
||||
related, err := o.ClosedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.ClosedByUser = o
|
||||
}
|
||||
|
||||
o.R.ClosedByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadClosedByCommunications loads the user's ClosedByCommunications into the .R struct
|
||||
func (os UserSlice) LoadClosedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.ClosedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.ClosedByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.ClosedBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.ClosedBy.IsValue() && o.ID == rel.ClosedBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.ClosedByUser = o
|
||||
|
||||
o.R.ClosedByCommunications = append(o.R.ClosedByCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadInvalidatedByCommunications loads the user's InvalidatedByCommunications into the .R struct
|
||||
func (o *User) LoadInvalidatedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.InvalidatedByCommunications = nil
|
||||
|
||||
related, err := o.InvalidatedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.InvalidatedByUser = o
|
||||
}
|
||||
|
||||
o.R.InvalidatedByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadInvalidatedByCommunications loads the user's InvalidatedByCommunications into the .R struct
|
||||
func (os UserSlice) LoadInvalidatedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.InvalidatedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.InvalidatedByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.InvalidatedBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.InvalidatedBy.IsValue() && o.ID == rel.InvalidatedBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.InvalidatedByUser = o
|
||||
|
||||
o.R.InvalidatedByCommunications = append(o.R.InvalidatedByCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOpenedByCommunications loads the user's OpenedByCommunications into the .R struct
|
||||
func (o *User) LoadOpenedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.OpenedByCommunications = nil
|
||||
|
||||
related, err := o.OpenedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.OpenedByUser = o
|
||||
}
|
||||
|
||||
o.R.OpenedByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOpenedByCommunications loads the user's OpenedByCommunications into the .R struct
|
||||
func (os UserSlice) LoadOpenedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.OpenedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.OpenedByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.OpenedBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.OpenedBy.IsValue() && o.ID == rel.OpenedBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.OpenedByUser = o
|
||||
|
||||
o.R.OpenedByCommunications = append(o.R.OpenedByCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPendingByCommunications loads the user's SetPendingByCommunications into the .R struct
|
||||
func (o *User) LoadSetPendingByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SetPendingByCommunications = nil
|
||||
|
||||
related, err := o.SetPendingByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPendingByUser = o
|
||||
}
|
||||
|
||||
o.R.SetPendingByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPendingByCommunications loads the user's SetPendingByCommunications into the .R struct
|
||||
func (os UserSlice) LoadSetPendingByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SetPendingByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SetPendingByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SetPendingBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SetPendingBy.IsValue() && o.ID == rel.SetPendingBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SetPendingByUser = o
|
||||
|
||||
o.R.SetPendingByCommunications = append(o.R.SetPendingByCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCreatorComplianceReportRequests loads the user's CreatorComplianceReportRequests into the .R struct
|
||||
func (o *User) LoadCreatorComplianceReportRequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue