Initial work marking communications
And a bunch of lint fixes
This commit is contained in:
parent
67c99436d1
commit
3153e8bf13
36 changed files with 1958 additions and 487 deletions
|
|
@ -87,6 +87,15 @@ var Communications = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
OrganizationID: column{
|
||||
Name: "organization_id",
|
||||
DBType: "integer",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
ResponseEmailLogID: column{
|
||||
Name: "response_email_log_id",
|
||||
DBType: "integer",
|
||||
|
|
@ -150,6 +159,42 @@ var Communications = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPossibleIssue: column{
|
||||
Name: "set_possible_issue",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPossibleIssueBy: column{
|
||||
Name: "set_possible_issue_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPossibleResolved: column{
|
||||
Name: "set_possible_resolved",
|
||||
DBType: "timestamp without time zone",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
SetPossibleResolvedBy: column{
|
||||
Name: "set_possible_resolved_by",
|
||||
DBType: "integer",
|
||||
Default: "NULL",
|
||||
Comment: "",
|
||||
Nullable: true,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
},
|
||||
Indexes: communicationIndexes{
|
||||
CommunicationPkey: index{
|
||||
|
|
@ -203,6 +248,15 @@ var Communications = Table[
|
|||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationOrganizationIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_organization_id_fkey",
|
||||
Columns: []string{"organization_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "organization",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationResponseEmailLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_response_email_log_id_fkey",
|
||||
|
|
@ -230,6 +284,24 @@ var Communications = Table[
|
|||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSetPossibleIssueByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_set_possible_issue_by_fkey",
|
||||
Columns: []string{"set_possible_issue_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSetPossibleResolvedByFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_set_possible_resolved_by_fkey",
|
||||
Columns: []string{"set_possible_resolved_by"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "user_",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
CommunicationCommunicationSourceEmailLogIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "communication.communication_source_email_log_id_fkey",
|
||||
|
|
@ -263,26 +335,31 @@ var Communications = Table[
|
|||
}
|
||||
|
||||
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
|
||||
Closed column
|
||||
ClosedBy column
|
||||
Created column
|
||||
ID column
|
||||
Invalidated column
|
||||
InvalidatedBy column
|
||||
Opened column
|
||||
OpenedBy column
|
||||
OrganizationID column
|
||||
ResponseEmailLogID column
|
||||
ResponseTextLogID column
|
||||
SetPending column
|
||||
SetPendingBy column
|
||||
SourceEmailLogID column
|
||||
SourceReportID column
|
||||
SourceTextLogID column
|
||||
SetPossibleIssue column
|
||||
SetPossibleIssueBy column
|
||||
SetPossibleResolved column
|
||||
SetPossibleResolvedBy 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,
|
||||
c.Closed, c.ClosedBy, c.Created, c.ID, c.Invalidated, c.InvalidatedBy, c.Opened, c.OpenedBy, c.OrganizationID, c.ResponseEmailLogID, c.ResponseTextLogID, c.SetPending, c.SetPendingBy, c.SourceEmailLogID, c.SourceReportID, c.SourceTextLogID, c.SetPossibleIssue, c.SetPossibleIssueBy, c.SetPossibleResolved, c.SetPossibleResolvedBy,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -297,20 +374,23 @@ func (i communicationIndexes) AsSlice() []index {
|
|||
}
|
||||
|
||||
type communicationForeignKeys struct {
|
||||
CommunicationCommunicationClosedByFkey foreignKey
|
||||
CommunicationCommunicationInvalidatedByFkey foreignKey
|
||||
CommunicationCommunicationOpenedByFkey foreignKey
|
||||
CommunicationCommunicationResponseEmailLogIDFkey foreignKey
|
||||
CommunicationCommunicationResponseTextLogIDFkey foreignKey
|
||||
CommunicationCommunicationSetPendingByFkey foreignKey
|
||||
CommunicationCommunicationSourceEmailLogIDFkey foreignKey
|
||||
CommunicationCommunicationSourceReportIDFkey foreignKey
|
||||
CommunicationCommunicationSourceTextLogIDFkey foreignKey
|
||||
CommunicationCommunicationClosedByFkey foreignKey
|
||||
CommunicationCommunicationInvalidatedByFkey foreignKey
|
||||
CommunicationCommunicationOpenedByFkey foreignKey
|
||||
CommunicationCommunicationOrganizationIDFkey foreignKey
|
||||
CommunicationCommunicationResponseEmailLogIDFkey foreignKey
|
||||
CommunicationCommunicationResponseTextLogIDFkey foreignKey
|
||||
CommunicationCommunicationSetPendingByFkey foreignKey
|
||||
CommunicationCommunicationSetPossibleIssueByFkey foreignKey
|
||||
CommunicationCommunicationSetPossibleResolvedByFkey 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,
|
||||
f.CommunicationCommunicationClosedByFkey, f.CommunicationCommunicationInvalidatedByFkey, f.CommunicationCommunicationOpenedByFkey, f.CommunicationCommunicationOrganizationIDFkey, f.CommunicationCommunicationResponseEmailLogIDFkey, f.CommunicationCommunicationResponseTextLogIDFkey, f.CommunicationCommunicationSetPendingByFkey, f.CommunicationCommunicationSetPossibleIssueByFkey, f.CommunicationCommunicationSetPossibleResolvedByFkey, f.CommunicationCommunicationSourceEmailLogIDFkey, f.CommunicationCommunicationSourceReportIDFkey, f.CommunicationCommunicationSourceTextLogIDFkey,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ var PublicreportCompliances = Table[
|
|||
},
|
||||
PermissionType: column{
|
||||
Name: "permission_type",
|
||||
DBType: "public.permissionaccesstype",
|
||||
DBType: "publicreport.permissionaccesstype",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
|
|
|
|||
|
|
@ -1283,85 +1283,6 @@ func (e *Notificationtype) Scan(value any) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Enum values for Permissionaccesstype
|
||||
const (
|
||||
PermissionaccesstypeDenied Permissionaccesstype = "denied"
|
||||
PermissionaccesstypeGranted Permissionaccesstype = "granted"
|
||||
PermissionaccesstypeUnselected Permissionaccesstype = "unselected"
|
||||
PermissionaccesstypeWithOwner Permissionaccesstype = "with-owner"
|
||||
)
|
||||
|
||||
func AllPermissionaccesstype() []Permissionaccesstype {
|
||||
return []Permissionaccesstype{
|
||||
PermissionaccesstypeDenied,
|
||||
PermissionaccesstypeGranted,
|
||||
PermissionaccesstypeUnselected,
|
||||
PermissionaccesstypeWithOwner,
|
||||
}
|
||||
}
|
||||
|
||||
type Permissionaccesstype string
|
||||
|
||||
func (e Permissionaccesstype) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e Permissionaccesstype) Valid() bool {
|
||||
switch e {
|
||||
case PermissionaccesstypeDenied,
|
||||
PermissionaccesstypeGranted,
|
||||
PermissionaccesstypeUnselected,
|
||||
PermissionaccesstypeWithOwner:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// useful when testing in other packages
|
||||
func (e Permissionaccesstype) All() []Permissionaccesstype {
|
||||
return AllPermissionaccesstype()
|
||||
}
|
||||
|
||||
func (e Permissionaccesstype) MarshalText() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *Permissionaccesstype) UnmarshalText(text []byte) error {
|
||||
return e.Scan(text)
|
||||
}
|
||||
|
||||
func (e Permissionaccesstype) MarshalBinary() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *Permissionaccesstype) UnmarshalBinary(data []byte) error {
|
||||
return e.Scan(data)
|
||||
}
|
||||
|
||||
func (e Permissionaccesstype) Value() (driver.Value, error) {
|
||||
return string(e), nil
|
||||
}
|
||||
|
||||
func (e *Permissionaccesstype) Scan(value any) error {
|
||||
switch x := value.(type) {
|
||||
case string:
|
||||
*e = Permissionaccesstype(x)
|
||||
case []byte:
|
||||
*e = Permissionaccesstype(x)
|
||||
case nil:
|
||||
return fmt.Errorf("cannot nil into Permissionaccesstype")
|
||||
default:
|
||||
return fmt.Errorf("cannot scan type %T: %v", value, value)
|
||||
}
|
||||
|
||||
if !e.Valid() {
|
||||
return fmt.Errorf("invalid Permissionaccesstype value: %s", *e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Enum values for Poolconditiontype
|
||||
const (
|
||||
PoolconditiontypeBlue Poolconditiontype = "blue"
|
||||
|
|
@ -1629,6 +1550,85 @@ func (e *PublicreportNuisancedurationtype) Scan(value any) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Enum values for PublicreportPermissionaccesstype
|
||||
const (
|
||||
PublicreportPermissionaccesstypeDenied PublicreportPermissionaccesstype = "denied"
|
||||
PublicreportPermissionaccesstypeGranted PublicreportPermissionaccesstype = "granted"
|
||||
PublicreportPermissionaccesstypeUnselected PublicreportPermissionaccesstype = "unselected"
|
||||
PublicreportPermissionaccesstypeWithOwner PublicreportPermissionaccesstype = "with-owner"
|
||||
)
|
||||
|
||||
func AllPublicreportPermissionaccesstype() []PublicreportPermissionaccesstype {
|
||||
return []PublicreportPermissionaccesstype{
|
||||
PublicreportPermissionaccesstypeDenied,
|
||||
PublicreportPermissionaccesstypeGranted,
|
||||
PublicreportPermissionaccesstypeUnselected,
|
||||
PublicreportPermissionaccesstypeWithOwner,
|
||||
}
|
||||
}
|
||||
|
||||
type PublicreportPermissionaccesstype string
|
||||
|
||||
func (e PublicreportPermissionaccesstype) String() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e PublicreportPermissionaccesstype) Valid() bool {
|
||||
switch e {
|
||||
case PublicreportPermissionaccesstypeDenied,
|
||||
PublicreportPermissionaccesstypeGranted,
|
||||
PublicreportPermissionaccesstypeUnselected,
|
||||
PublicreportPermissionaccesstypeWithOwner:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// useful when testing in other packages
|
||||
func (e PublicreportPermissionaccesstype) All() []PublicreportPermissionaccesstype {
|
||||
return AllPublicreportPermissionaccesstype()
|
||||
}
|
||||
|
||||
func (e PublicreportPermissionaccesstype) MarshalText() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportPermissionaccesstype) UnmarshalText(text []byte) error {
|
||||
return e.Scan(text)
|
||||
}
|
||||
|
||||
func (e PublicreportPermissionaccesstype) MarshalBinary() ([]byte, error) {
|
||||
return []byte(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportPermissionaccesstype) UnmarshalBinary(data []byte) error {
|
||||
return e.Scan(data)
|
||||
}
|
||||
|
||||
func (e PublicreportPermissionaccesstype) Value() (driver.Value, error) {
|
||||
return string(e), nil
|
||||
}
|
||||
|
||||
func (e *PublicreportPermissionaccesstype) Scan(value any) error {
|
||||
switch x := value.(type) {
|
||||
case string:
|
||||
*e = PublicreportPermissionaccesstype(x)
|
||||
case []byte:
|
||||
*e = PublicreportPermissionaccesstype(x)
|
||||
case nil:
|
||||
return fmt.Errorf("cannot nil into PublicreportPermissionaccesstype")
|
||||
default:
|
||||
return fmt.Errorf("cannot scan type %T: %v", value, value)
|
||||
}
|
||||
|
||||
if !e.Valid() {
|
||||
return fmt.Errorf("invalid PublicreportPermissionaccesstype value: %s", *e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Enum values for PublicreportPoolsourceduration
|
||||
const (
|
||||
PublicreportPoolsourcedurationNone PublicreportPoolsourceduration = "none"
|
||||
|
|
|
|||
6
db/migrations/00150_communication_possible_status.sql
Normal file
6
db/migrations/00150_communication_possible_status.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE communication
|
||||
ADD COLUMN set_possible_issue TIMESTAMP WITHOUT TIME ZONE,
|
||||
ADD COLUMN set_possible_issue_by INTEGER REFERENCES user_(id),
|
||||
ADD COLUMN set_possible_resolved TIMESTAMP WITHOUT TIME ZONE,
|
||||
ADD COLUMN set_possible_resolved_by INTEGER REFERENCES user_(id);
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -78,6 +78,7 @@ type OrganizationsQuery = *psql.ViewQuery[*Organization, OrganizationSlice]
|
|||
|
||||
// organizationR is where relationships are stored.
|
||||
type organizationR struct {
|
||||
Communications CommunicationSlice // communication.communication_organization_id_fkey
|
||||
EmailContacts CommsEmailContactSlice // district_subscription_email.district_subscription_email_email_contact_address_fkeydistrict_subscription_email.district_subscription_email_organization_id_fkey
|
||||
Phones CommsPhoneSlice // district_subscription_phone.district_subscription_phone_organization_id_fkeydistrict_subscription_phone.district_subscription_phone_phone_e164_fkey
|
||||
Features FeatureSlice // feature.feature_organization_id_fkey
|
||||
|
|
@ -972,6 +973,30 @@ func (o OrganizationSlice) ReloadAll(ctx context.Context, exec bob.Executor) err
|
|||
return nil
|
||||
}
|
||||
|
||||
// Communications starts a query for related objects on communication
|
||||
func (o *Organization) Communications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.OrganizationID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os OrganizationSlice) Communications(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.OrganizationID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// EmailContacts starts a query for related objects on comms.email_contact
|
||||
func (o *Organization) EmailContacts(mods ...bob.Mod[*dialect.SelectQuery]) CommsEmailContactsQuery {
|
||||
return CommsEmailContacts.Query(append(mods,
|
||||
|
|
@ -1990,6 +2015,74 @@ func (os OrganizationSlice) User(mods ...bob.Mod[*dialect.SelectQuery]) UsersQue
|
|||
)...)
|
||||
}
|
||||
|
||||
func insertOrganizationCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, organization0 *Organization) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].OrganizationID = omit.From(organization0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertOrganizationCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachOrganizationCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, organization0 *Organization) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
OrganizationID: omit.From(organization0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachOrganizationCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) InsertCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertOrganizationCommunications0(ctx, exec, related, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Communications = append(organization0.R.Communications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) AttachCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachOrganizationCommunications0(ctx, exec, len(related), communications1, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Communications = append(organization0.R.Communications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func attachOrganizationEmailContacts0(ctx context.Context, exec bob.Executor, count int, organization0 *Organization, commsEmailContacts2 CommsEmailContactSlice) (DistrictSubscriptionEmailSlice, error) {
|
||||
setters := make([]*DistrictSubscriptionEmailSetter, count)
|
||||
for i := range count {
|
||||
|
|
@ -4928,6 +5021,20 @@ func (o *Organization) Preload(name string, retrieved any) error {
|
|||
}
|
||||
|
||||
switch name {
|
||||
case "Communications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("organization cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Communications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "EmailContacts":
|
||||
rels, ok := retrieved.(CommsEmailContactSlice)
|
||||
if !ok {
|
||||
|
|
@ -5528,6 +5635,7 @@ func buildOrganizationPreloader() organizationPreloader {
|
|||
}
|
||||
|
||||
type organizationThenLoader[Q orm.Loadable] struct {
|
||||
Communications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
EmailContacts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Phones func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Features func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
|
|
@ -5573,6 +5681,9 @@ type organizationThenLoader[Q orm.Loadable] struct {
|
|||
}
|
||||
|
||||
func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
||||
type CommunicationsLoadInterface interface {
|
||||
LoadCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type EmailContactsLoadInterface interface {
|
||||
LoadEmailContacts(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -5701,6 +5812,12 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
}
|
||||
|
||||
return organizationThenLoader[Q]{
|
||||
Communications: thenLoadBuilder[Q](
|
||||
"Communications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved CommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
EmailContacts: thenLoadBuilder[Q](
|
||||
"EmailContacts",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved EmailContactsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -5956,6 +6073,67 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
}
|
||||
}
|
||||
|
||||
// LoadCommunications loads the organization's Communications into the .R struct
|
||||
func (o *Organization) LoadCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Communications = nil
|
||||
|
||||
related, err := o.Communications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
|
||||
o.R.Communications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCommunications loads the organization's Communications into the .R struct
|
||||
func (os OrganizationSlice) LoadCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.Communications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.Communications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !(o.ID == rel.OrganizationID) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.Organization = o
|
||||
|
||||
o.R.Communications = append(o.R.Communications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadEmailContacts loads the organization's EmailContacts into the .R struct
|
||||
func (o *Organization) LoadEmailContacts(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ import (
|
|||
|
||||
// PublicreportCompliance is an object representing the database table.
|
||||
type PublicreportCompliance struct {
|
||||
AccessInstructions string `db:"access_instructions" `
|
||||
AvailabilityNotes string `db:"availability_notes" `
|
||||
Comments string `db:"comments" `
|
||||
GateCode string `db:"gate_code" `
|
||||
HasDog null.Val[bool] `db:"has_dog" `
|
||||
PermissionType enums.Permissionaccesstype `db:"permission_type" `
|
||||
ReportID int32 `db:"report_id,pk" `
|
||||
ReportPhoneCanText null.Val[bool] `db:"report_phone_can_text" `
|
||||
WantsScheduled null.Val[bool] `db:"wants_scheduled" `
|
||||
Submitted null.Val[time.Time] `db:"submitted" `
|
||||
AccessInstructions string `db:"access_instructions" `
|
||||
AvailabilityNotes string `db:"availability_notes" `
|
||||
Comments string `db:"comments" `
|
||||
GateCode string `db:"gate_code" `
|
||||
HasDog null.Val[bool] `db:"has_dog" `
|
||||
PermissionType enums.PublicreportPermissionaccesstype `db:"permission_type" `
|
||||
ReportID int32 `db:"report_id,pk" `
|
||||
ReportPhoneCanText null.Val[bool] `db:"report_phone_can_text" `
|
||||
WantsScheduled null.Val[bool] `db:"wants_scheduled" `
|
||||
Submitted null.Val[time.Time] `db:"submitted" `
|
||||
|
||||
R publicreportComplianceR `db:"-" `
|
||||
}
|
||||
|
|
@ -101,16 +101,16 @@ func (publicreportComplianceColumns) AliasedAs(alias string) publicreportComplia
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type PublicreportComplianceSetter struct {
|
||||
AccessInstructions omit.Val[string] `db:"access_instructions" `
|
||||
AvailabilityNotes omit.Val[string] `db:"availability_notes" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
GateCode omit.Val[string] `db:"gate_code" `
|
||||
HasDog omitnull.Val[bool] `db:"has_dog" `
|
||||
PermissionType omit.Val[enums.Permissionaccesstype] `db:"permission_type" `
|
||||
ReportID omit.Val[int32] `db:"report_id,pk" `
|
||||
ReportPhoneCanText omitnull.Val[bool] `db:"report_phone_can_text" `
|
||||
WantsScheduled omitnull.Val[bool] `db:"wants_scheduled" `
|
||||
Submitted omitnull.Val[time.Time] `db:"submitted" `
|
||||
AccessInstructions omit.Val[string] `db:"access_instructions" `
|
||||
AvailabilityNotes omit.Val[string] `db:"availability_notes" `
|
||||
Comments omit.Val[string] `db:"comments" `
|
||||
GateCode omit.Val[string] `db:"gate_code" `
|
||||
HasDog omitnull.Val[bool] `db:"has_dog" `
|
||||
PermissionType omit.Val[enums.PublicreportPermissionaccesstype] `db:"permission_type" `
|
||||
ReportID omit.Val[int32] `db:"report_id,pk" `
|
||||
ReportPhoneCanText omitnull.Val[bool] `db:"report_phone_can_text" `
|
||||
WantsScheduled omitnull.Val[bool] `db:"wants_scheduled" `
|
||||
Submitted omitnull.Val[time.Time] `db:"submitted" `
|
||||
}
|
||||
|
||||
func (s PublicreportComplianceSetter) SetColumns() []string {
|
||||
|
|
@ -633,7 +633,7 @@ type publicreportComplianceWhere[Q psql.Filterable] struct {
|
|||
Comments psql.WhereMod[Q, string]
|
||||
GateCode psql.WhereMod[Q, string]
|
||||
HasDog psql.WhereNullMod[Q, bool]
|
||||
PermissionType psql.WhereMod[Q, enums.Permissionaccesstype]
|
||||
PermissionType psql.WhereMod[Q, enums.PublicreportPermissionaccesstype]
|
||||
ReportID psql.WhereMod[Q, int32]
|
||||
ReportPhoneCanText psql.WhereNullMod[Q, bool]
|
||||
WantsScheduled psql.WhereNullMod[Q, bool]
|
||||
|
|
@ -651,7 +651,7 @@ func buildPublicreportComplianceWhere[Q psql.Filterable](cols publicreportCompli
|
|||
Comments: psql.Where[Q, string](cols.Comments),
|
||||
GateCode: psql.Where[Q, string](cols.GateCode),
|
||||
HasDog: psql.WhereNull[Q, bool](cols.HasDog),
|
||||
PermissionType: psql.Where[Q, enums.Permissionaccesstype](cols.PermissionType),
|
||||
PermissionType: psql.Where[Q, enums.PublicreportPermissionaccesstype](cols.PermissionType),
|
||||
ReportID: psql.Where[Q, int32](cols.ReportID),
|
||||
ReportPhoneCanText: psql.WhereNull[Q, bool](cols.ReportPhoneCanText),
|
||||
WantsScheduled: psql.WhereNull[Q, bool](cols.WantsScheduled),
|
||||
|
|
|
|||
|
|
@ -60,36 +60,38 @@ type UsersQuery = *psql.ViewQuery[*User, UserSlice]
|
|||
|
||||
// userR is where relationships are stored.
|
||||
type userR struct {
|
||||
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
|
||||
CreatorFiles FileuploadFileSlice // fileupload.file.file_creator_id_fkey
|
||||
FileuploadPool FileuploadPoolSlice // fileupload.pool.pool_creator_id_fkey
|
||||
CreatorLeads LeadSlice // lead.lead_creator_fkey
|
||||
ImpersonatorLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_impersonator_id_fkey
|
||||
TargetLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_target_id_fkey
|
||||
CreatorNoteAudios NoteAudioSlice // note_audio.note_audio_creator_id_fkey
|
||||
DeletorNoteAudios NoteAudioSlice // note_audio.note_audio_deletor_id_fkey
|
||||
CreatorNoteImages NoteImageSlice // note_image.note_image_creator_id_fkey
|
||||
DeletorNoteImages NoteImageSlice // note_image.note_image_deletor_id_fkey
|
||||
UserNotifications NotificationSlice // notification.notification_user_id_fkey
|
||||
ReviewerNuisanceOlds PublicreportNuisanceOldSlice // publicreport.nuisance_old.nuisance_reviewer_id_fkey
|
||||
ReviewerReports PublicreportReportSlice // publicreport.report.report_reviewer_id_fkey
|
||||
UserReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_user_id_fkey
|
||||
ReviewerWaterOlds PublicreportWaterOldSlice // publicreport.water_old.water_reviewer_id_fkey
|
||||
CreatorReportTexts ReportTextSlice // report_text.report_text_creator_id_fkey
|
||||
CreatorResidents ResidentSlice // resident.resident_creator_fkey
|
||||
CreatorReviewTasks ReviewTaskSlice // review_task.review_task_creator_id_fkey
|
||||
ReviewerReviewTasks ReviewTaskSlice // review_task.review_task_reviewer_id_fkey
|
||||
AddressorSignals SignalSlice // signal.signal_addressor_fkey
|
||||
CreatorSignals SignalSlice // signal.signal_creator_fkey
|
||||
CreatorSites SiteSlice // site.site_creator_id_fkey
|
||||
Organization *Organization // user_.user__organization_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
|
||||
SetPossibleIssueByCommunications CommunicationSlice // communication.communication_set_possible_issue_by_fkey
|
||||
SetPossibleResolvedByCommunications CommunicationSlice // communication.communication_set_possible_resolved_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
|
||||
CreatorFiles FileuploadFileSlice // fileupload.file.file_creator_id_fkey
|
||||
FileuploadPool FileuploadPoolSlice // fileupload.pool.pool_creator_id_fkey
|
||||
CreatorLeads LeadSlice // lead.lead_creator_fkey
|
||||
ImpersonatorLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_impersonator_id_fkey
|
||||
TargetLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_target_id_fkey
|
||||
CreatorNoteAudios NoteAudioSlice // note_audio.note_audio_creator_id_fkey
|
||||
DeletorNoteAudios NoteAudioSlice // note_audio.note_audio_deletor_id_fkey
|
||||
CreatorNoteImages NoteImageSlice // note_image.note_image_creator_id_fkey
|
||||
DeletorNoteImages NoteImageSlice // note_image.note_image_deletor_id_fkey
|
||||
UserNotifications NotificationSlice // notification.notification_user_id_fkey
|
||||
ReviewerNuisanceOlds PublicreportNuisanceOldSlice // publicreport.nuisance_old.nuisance_reviewer_id_fkey
|
||||
ReviewerReports PublicreportReportSlice // publicreport.report.report_reviewer_id_fkey
|
||||
UserReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_user_id_fkey
|
||||
ReviewerWaterOlds PublicreportWaterOldSlice // publicreport.water_old.water_reviewer_id_fkey
|
||||
CreatorReportTexts ReportTextSlice // report_text.report_text_creator_id_fkey
|
||||
CreatorResidents ResidentSlice // resident.resident_creator_fkey
|
||||
CreatorReviewTasks ReviewTaskSlice // review_task.review_task_creator_id_fkey
|
||||
ReviewerReviewTasks ReviewTaskSlice // review_task.review_task_reviewer_id_fkey
|
||||
AddressorSignals SignalSlice // signal.signal_addressor_fkey
|
||||
CreatorSignals SignalSlice // signal.signal_creator_fkey
|
||||
CreatorSites SiteSlice // site.site_creator_id_fkey
|
||||
Organization *Organization // user_.user__organization_id_fkey
|
||||
}
|
||||
|
||||
func buildUserColumns(alias string) userColumns {
|
||||
|
|
@ -866,6 +868,54 @@ func (os UserSlice) SetPendingByCommunications(mods ...bob.Mod[*dialect.SelectQu
|
|||
)...)
|
||||
}
|
||||
|
||||
// SetPossibleIssueByCommunications starts a query for related objects on communication
|
||||
func (o *User) SetPossibleIssueByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SetPossibleIssueBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) SetPossibleIssueByCommunications(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.SetPossibleIssueBy).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// SetPossibleResolvedByCommunications starts a query for related objects on communication
|
||||
func (o *User) SetPossibleResolvedByCommunications(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationsQuery {
|
||||
return Communications.Query(append(mods,
|
||||
sm.Where(Communications.Columns.SetPossibleResolvedBy.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os UserSlice) SetPossibleResolvedByCommunications(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.SetPossibleResolvedBy).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,
|
||||
|
|
@ -1806,6 +1856,142 @@ func (user0 *User) AttachSetPendingByCommunications(ctx context.Context, exec bo
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertUserSetPossibleIssueByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SetPossibleIssueBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserSetPossibleIssueByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserSetPossibleIssueByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SetPossibleIssueBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserSetPossibleIssueByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertSetPossibleIssueByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserSetPossibleIssueByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPossibleIssueByCommunications = append(user0.R.SetPossibleIssueByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SetPossibleIssueByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachSetPossibleIssueByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserSetPossibleIssueByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPossibleIssueByCommunications = append(user0.R.SetPossibleIssueByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPossibleIssueByUser = user0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertUserSetPossibleResolvedByCommunications0(ctx context.Context, exec bob.Executor, communications1 []*CommunicationSetter, user0 *User) (CommunicationSlice, error) {
|
||||
for i := range communications1 {
|
||||
communications1[i].SetPossibleResolvedBy = omitnull.From(user0.ID)
|
||||
}
|
||||
|
||||
ret, err := Communications.Insert(bob.ToMods(communications1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertUserSetPossibleResolvedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachUserSetPossibleResolvedByCommunications0(ctx context.Context, exec bob.Executor, count int, communications1 CommunicationSlice, user0 *User) (CommunicationSlice, error) {
|
||||
setter := &CommunicationSetter{
|
||||
SetPossibleResolvedBy: omitnull.From(user0.ID),
|
||||
}
|
||||
|
||||
err := communications1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachUserSetPossibleResolvedByCommunications0: %w", err)
|
||||
}
|
||||
|
||||
return communications1, nil
|
||||
}
|
||||
|
||||
func (user0 *User) InsertSetPossibleResolvedByCommunications(ctx context.Context, exec bob.Executor, related ...*CommunicationSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
communications1, err := insertUserSetPossibleResolvedByCommunications0(ctx, exec, related, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPossibleResolvedByCommunications = append(user0.R.SetPossibleResolvedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range communications1 {
|
||||
rel.R.SetPossibleResolvedByUser = user0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (user0 *User) AttachSetPossibleResolvedByCommunications(ctx context.Context, exec bob.Executor, related ...*Communication) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
communications1 := CommunicationSlice(related)
|
||||
|
||||
_, err = attachUserSetPossibleResolvedByCommunications0(ctx, exec, len(related), communications1, user0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user0.R.SetPossibleResolvedByCommunications = append(user0.R.SetPossibleResolvedByCommunications, communications1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPossibleResolvedByUser = 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)
|
||||
|
|
@ -3608,6 +3794,34 @@ func (o *User) Preload(name string, retrieved any) error {
|
|||
}
|
||||
}
|
||||
return nil
|
||||
case "SetPossibleIssueByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SetPossibleIssueByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SetPossibleIssueByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "SetPossibleResolvedByCommunications":
|
||||
rels, ok := retrieved.(CommunicationSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.SetPossibleResolvedByCommunications = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.SetPossibleResolvedByUser = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "CreatorComplianceReportRequests":
|
||||
rels, ok := retrieved.(ComplianceReportRequestSlice)
|
||||
if !ok {
|
||||
|
|
@ -3984,36 +4198,38 @@ func buildUserPreloader() userPreloader {
|
|||
}
|
||||
|
||||
type userThenLoader[Q orm.Loadable] struct {
|
||||
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]
|
||||
CreatorFiles func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
FileuploadPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorLeads func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ImpersonatorLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
TargetLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
UserNotifications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerNuisanceOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerReports func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
UserReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerWaterOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorResidents func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
AddressorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorSites func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Organization 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]
|
||||
SetPossibleIssueByCommunications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
SetPossibleResolvedByCommunications 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]
|
||||
CreatorFiles func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
FileuploadPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorLeads func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ImpersonatorLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
TargetLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
UserNotifications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerNuisanceOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerReports func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
UserReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerWaterOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorResidents func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ReviewerReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
AddressorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CreatorSites func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
||||
func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
||||
|
|
@ -4032,6 +4248,12 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
|||
type SetPendingByCommunicationsLoadInterface interface {
|
||||
LoadSetPendingByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SetPossibleIssueByCommunicationsLoadInterface interface {
|
||||
LoadSetPossibleIssueByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type SetPossibleResolvedByCommunicationsLoadInterface interface {
|
||||
LoadSetPossibleResolvedByCommunications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type CreatorComplianceReportRequestsLoadInterface interface {
|
||||
LoadCreatorComplianceReportRequests(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -4139,6 +4361,18 @@ func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
|||
return retrieved.LoadSetPendingByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SetPossibleIssueByCommunications: thenLoadBuilder[Q](
|
||||
"SetPossibleIssueByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SetPossibleIssueByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSetPossibleIssueByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
SetPossibleResolvedByCommunications: thenLoadBuilder[Q](
|
||||
"SetPossibleResolvedByCommunications",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved SetPossibleResolvedByCommunicationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadSetPossibleResolvedByCommunications(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
CreatorComplianceReportRequests: thenLoadBuilder[Q](
|
||||
"CreatorComplianceReportRequests",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved CreatorComplianceReportRequestsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -4612,6 +4846,134 @@ func (os UserSlice) LoadSetPendingByCommunications(ctx context.Context, exec bob
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPossibleIssueByCommunications loads the user's SetPossibleIssueByCommunications into the .R struct
|
||||
func (o *User) LoadSetPossibleIssueByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SetPossibleIssueByCommunications = nil
|
||||
|
||||
related, err := o.SetPossibleIssueByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPossibleIssueByUser = o
|
||||
}
|
||||
|
||||
o.R.SetPossibleIssueByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPossibleIssueByCommunications loads the user's SetPossibleIssueByCommunications into the .R struct
|
||||
func (os UserSlice) LoadSetPossibleIssueByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SetPossibleIssueByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SetPossibleIssueByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SetPossibleIssueBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SetPossibleIssueBy.IsValue() && o.ID == rel.SetPossibleIssueBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SetPossibleIssueByUser = o
|
||||
|
||||
o.R.SetPossibleIssueByCommunications = append(o.R.SetPossibleIssueByCommunications, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPossibleResolvedByCommunications loads the user's SetPossibleResolvedByCommunications into the .R struct
|
||||
func (o *User) LoadSetPossibleResolvedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.SetPossibleResolvedByCommunications = nil
|
||||
|
||||
related, err := o.SetPossibleResolvedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.SetPossibleResolvedByUser = o
|
||||
}
|
||||
|
||||
o.R.SetPossibleResolvedByCommunications = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadSetPossibleResolvedByCommunications loads the user's SetPossibleResolvedByCommunications into the .R struct
|
||||
func (os UserSlice) LoadSetPossibleResolvedByCommunications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
communications, err := os.SetPossibleResolvedByCommunications(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.SetPossibleResolvedByCommunications = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range communications {
|
||||
|
||||
if !rel.SetPossibleResolvedBy.IsValue() {
|
||||
continue
|
||||
}
|
||||
if !(rel.SetPossibleResolvedBy.IsValue() && o.ID == rel.SetPossibleResolvedBy.MustGet()) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.SetPossibleResolvedByUser = o
|
||||
|
||||
o.R.SetPossibleResolvedByCommunications = append(o.R.SetPossibleResolvedByCommunications, 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 {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,13 @@ func CommunicationInsert(ctx context.Context, txn bob.Tx, m *model.Communication
|
|||
RETURNING(table.Communication.AllColumns)
|
||||
return db.ExecuteOne[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationFromID(ctx context.Context, comm_id int64) (*model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.ID.EQ(postgres.Int(comm_id)))
|
||||
return db.ExecuteOne[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationsFromOrganization(ctx context.Context, org_id int64) ([]*model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
|
|
@ -25,3 +32,35 @@ func CommunicationsFromOrganization(ctx context.Context, org_id int64) ([]*model
|
|||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)))
|
||||
return db.ExecuteMany[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationMarkInvalid(ctx context.Context, org_id int64, user_id int64, comm_id int64) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(table.Communication.Invalidated.SET(postgres.LOCALTIMESTAMP())).
|
||||
SET(table.Communication.InvalidatedBy.SET(postgres.Int(user_id))).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
|
||||
table.Communication.ID.EQ(postgres.Int(comm_id))))
|
||||
return db.ExecuteNone(ctx, statement)
|
||||
}
|
||||
func CommunicationMarkPendingResponse(ctx context.Context, org_id int64, user_id int64, comm_id int64) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(table.Communication.SetPending.SET(postgres.LOCALTIMESTAMP())).
|
||||
SET(table.Communication.SetPendingBy.SET(postgres.Int(user_id))).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
|
||||
table.Communication.ID.EQ(postgres.Int(comm_id))))
|
||||
return db.ExecuteNone(ctx, statement)
|
||||
}
|
||||
func CommunicationMarkPossibleIssue(ctx context.Context, org_id int64, user_id int64, comm_id int64) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(table.Communication.SetPossibleIssue.SET(postgres.LOCALTIMESTAMP())).
|
||||
SET(table.Communication.SetPossibleIssueBy.SET(postgres.Int(user_id))).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
|
||||
table.Communication.ID.EQ(postgres.Int(comm_id))))
|
||||
return db.ExecuteNone(ctx, statement)
|
||||
}
|
||||
func CommunicationMarkPossibleResolved(ctx context.Context, org_id int64, user_id int64, comm_id int64) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(table.Communication.SetPossibleResolved.SET(postgres.LOCALTIMESTAMP())).
|
||||
SET(table.Communication.SetPossibleResolvedBy.SET(postgres.Int(user_id))).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id)).AND(
|
||||
table.Communication.ID.EQ(postgres.Int(comm_id))))
|
||||
return db.ExecuteNone(ctx, statement)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue