Remove organization from fileupload.pool table, fix in district logic
This commit is contained in:
parent
8e00d3e04b
commit
9c3d2ba3df
12 changed files with 69 additions and 739 deletions
|
|
@ -141,15 +141,6 @@ var FileuploadPools = Table[
|
|||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
OrganizationID: column{
|
||||
Name: "organization_id",
|
||||
DBType: "integer",
|
||||
Default: "",
|
||||
Comment: "",
|
||||
Nullable: false,
|
||||
Generated: false,
|
||||
AutoIncr: false,
|
||||
},
|
||||
PropertyOwnerName: column{
|
||||
Name: "property_owner_name",
|
||||
DBType: "text",
|
||||
|
|
@ -275,15 +266,6 @@ var FileuploadPools = Table[
|
|||
ForeignTable: "fileupload.csv",
|
||||
ForeignColumns: []string{"file_id"},
|
||||
},
|
||||
FileuploadPoolPoolOrganizationIDFkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "fileupload.pool.pool_organization_id_fkey",
|
||||
Columns: []string{"organization_id"},
|
||||
Comment: "",
|
||||
},
|
||||
ForeignTable: "organization",
|
||||
ForeignColumns: []string{"id"},
|
||||
},
|
||||
FileuploadPoolPoolPropertyOwnerPhoneE164Fkey: foreignKey{
|
||||
constraint: constraint{
|
||||
Name: "fileupload.pool.pool_property_owner_phone_e164_fkey",
|
||||
|
|
@ -322,7 +304,6 @@ type fileuploadPoolColumns struct {
|
|||
IsInDistrict column
|
||||
IsNew column
|
||||
Notes column
|
||||
OrganizationID column
|
||||
PropertyOwnerName column
|
||||
PropertyOwnerPhoneE164 column
|
||||
ResidentOwned column
|
||||
|
|
@ -336,7 +317,7 @@ type fileuploadPoolColumns struct {
|
|||
|
||||
func (c fileuploadPoolColumns) AsSlice() []column {
|
||||
return []column{
|
||||
c.AddressPostalCode, c.AddressStreet, c.Committed, c.Condition, c.Created, c.CreatorID, c.CSVFile, c.Deleted, c.Geom, c.H3cell, c.ID, c.IsInDistrict, c.IsNew, c.Notes, c.OrganizationID, c.PropertyOwnerName, c.PropertyOwnerPhoneE164, c.ResidentOwned, c.ResidentPhoneE164, c.LineNumber, c.Tags, c.AddressNumber, c.AddressLocality, c.AddressRegion,
|
||||
c.AddressPostalCode, c.AddressStreet, c.Committed, c.Condition, c.Created, c.CreatorID, c.CSVFile, c.Deleted, c.Geom, c.H3cell, c.ID, c.IsInDistrict, c.IsNew, c.Notes, c.PropertyOwnerName, c.PropertyOwnerPhoneE164, c.ResidentOwned, c.ResidentPhoneE164, c.LineNumber, c.Tags, c.AddressNumber, c.AddressLocality, c.AddressRegion,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -353,14 +334,13 @@ func (i fileuploadPoolIndexes) AsSlice() []index {
|
|||
type fileuploadPoolForeignKeys struct {
|
||||
FileuploadPoolPoolCreatorIDFkey foreignKey
|
||||
FileuploadPoolPoolCSVFileFkey foreignKey
|
||||
FileuploadPoolPoolOrganizationIDFkey foreignKey
|
||||
FileuploadPoolPoolPropertyOwnerPhoneE164Fkey foreignKey
|
||||
FileuploadPoolPoolResidentPhoneE164Fkey foreignKey
|
||||
}
|
||||
|
||||
func (f fileuploadPoolForeignKeys) AsSlice() []foreignKey {
|
||||
return []foreignKey{
|
||||
f.FileuploadPoolPoolCreatorIDFkey, f.FileuploadPoolPoolCSVFileFkey, f.FileuploadPoolPoolOrganizationIDFkey, f.FileuploadPoolPoolPropertyOwnerPhoneE164Fkey, f.FileuploadPoolPoolResidentPhoneE164Fkey,
|
||||
f.FileuploadPoolPoolCreatorIDFkey, f.FileuploadPoolPoolCSVFileFkey, f.FileuploadPoolPoolPropertyOwnerPhoneE164Fkey, f.FileuploadPoolPoolResidentPhoneE164Fkey,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -270,7 +270,6 @@ var (
|
|||
fileuploadPoolWithParentsCascadingCtx = newContextual[bool]("fileuploadPoolWithParentsCascading")
|
||||
fileuploadPoolRelCreatorUserCtx = newContextual[bool]("fileupload.pool.user_.fileupload.pool.pool_creator_id_fkey")
|
||||
fileuploadPoolRelCSVFileCSVCtx = newContextual[bool]("fileupload.csv.fileupload.pool.fileupload.pool.pool_csv_file_fkey")
|
||||
fileuploadPoolRelOrganizationCtx = newContextual[bool]("fileupload.pool.organization.fileupload.pool.pool_organization_id_fkey")
|
||||
fileuploadPoolRelPropertyOwnerPhoneE164PhoneCtx = newContextual[bool]("comms.phone.fileupload.pool.fileupload.pool.pool_property_owner_phone_e164_fkey")
|
||||
fileuploadPoolRelResidentPhoneE164PhoneCtx = newContextual[bool]("comms.phone.fileupload.pool.fileupload.pool.pool_resident_phone_e164_fkey")
|
||||
|
||||
|
|
@ -359,7 +358,6 @@ var (
|
|||
organizationRelZones2sCtx = newContextual[bool]("fieldseeker.zones2.organization.fieldseeker.zones2.zones2_organization_id_fkey")
|
||||
organizationRelFieldseekerSyncsCtx = newContextual[bool]("fieldseeker_sync.organization.fieldseeker_sync.fieldseeker_sync_organization_id_fkey")
|
||||
organizationRelFilesCtx = newContextual[bool]("fileupload.file.organization.fileupload.file.file_organization_id_fkey")
|
||||
organizationRelPoolsCtx = newContextual[bool]("fileupload.pool.organization.fileupload.pool.pool_organization_id_fkey")
|
||||
organizationRelH3AggregationsCtx = newContextual[bool]("h3_aggregation.organization.h3_aggregation.h3_aggregation_organization_id_fkey")
|
||||
organizationRelNoteAudiosCtx = newContextual[bool]("note_audio.organization.note_audio.note_audio_organization_id_fkey")
|
||||
organizationRelNoteImagesCtx = newContextual[bool]("note_image.organization.note_image.note_image_organization_id_fkey")
|
||||
|
|
|
|||
|
|
@ -2913,7 +2913,6 @@ func (f *Factory) FromExistingFileuploadPool(m *models.FileuploadPool) *Fileuplo
|
|||
o.IsInDistrict = func() bool { return m.IsInDistrict }
|
||||
o.IsNew = func() bool { return m.IsNew }
|
||||
o.Notes = func() string { return m.Notes }
|
||||
o.OrganizationID = func() int32 { return m.OrganizationID }
|
||||
o.PropertyOwnerName = func() string { return m.PropertyOwnerName }
|
||||
o.PropertyOwnerPhoneE164 = func() null.Val[string] { return m.PropertyOwnerPhoneE164 }
|
||||
o.ResidentOwned = func() null.Val[bool] { return m.ResidentOwned }
|
||||
|
|
@ -2931,9 +2930,6 @@ func (f *Factory) FromExistingFileuploadPool(m *models.FileuploadPool) *Fileuplo
|
|||
if m.R.CSVFileCSV != nil {
|
||||
FileuploadPoolMods.WithExistingCSVFileCSV(m.R.CSVFileCSV).Apply(ctx, o)
|
||||
}
|
||||
if m.R.Organization != nil {
|
||||
FileuploadPoolMods.WithExistingOrganization(m.R.Organization).Apply(ctx, o)
|
||||
}
|
||||
if m.R.PropertyOwnerPhoneE164Phone != nil {
|
||||
FileuploadPoolMods.WithExistingPropertyOwnerPhoneE164Phone(m.R.PropertyOwnerPhoneE164Phone).Apply(ctx, o)
|
||||
}
|
||||
|
|
@ -3485,9 +3481,6 @@ func (f *Factory) FromExistingOrganization(m *models.Organization) *Organization
|
|||
if len(m.R.Files) > 0 {
|
||||
OrganizationMods.AddExistingFiles(m.R.Files...).Apply(ctx, o)
|
||||
}
|
||||
if len(m.R.Pools) > 0 {
|
||||
OrganizationMods.AddExistingPools(m.R.Pools...).Apply(ctx, o)
|
||||
}
|
||||
if len(m.R.H3Aggregations) > 0 {
|
||||
OrganizationMods.AddExistingH3Aggregations(m.R.H3Aggregations...).Apply(ctx, o)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ type FileuploadPoolTemplate struct {
|
|||
IsInDistrict func() bool
|
||||
IsNew func() bool
|
||||
Notes func() string
|
||||
OrganizationID func() int32
|
||||
PropertyOwnerName func() string
|
||||
PropertyOwnerPhoneE164 func() null.Val[string]
|
||||
ResidentOwned func() null.Val[bool]
|
||||
|
|
@ -73,7 +72,6 @@ type FileuploadPoolTemplate struct {
|
|||
type fileuploadPoolR struct {
|
||||
CreatorUser *fileuploadPoolRCreatorUserR
|
||||
CSVFileCSV *fileuploadPoolRCSVFileCSVR
|
||||
Organization *fileuploadPoolROrganizationR
|
||||
PropertyOwnerPhoneE164Phone *fileuploadPoolRPropertyOwnerPhoneE164PhoneR
|
||||
ResidentPhoneE164Phone *fileuploadPoolRResidentPhoneE164PhoneR
|
||||
}
|
||||
|
|
@ -84,9 +82,6 @@ type fileuploadPoolRCreatorUserR struct {
|
|||
type fileuploadPoolRCSVFileCSVR struct {
|
||||
o *FileuploadCSVTemplate
|
||||
}
|
||||
type fileuploadPoolROrganizationR struct {
|
||||
o *OrganizationTemplate
|
||||
}
|
||||
type fileuploadPoolRPropertyOwnerPhoneE164PhoneR struct {
|
||||
o *CommsPhoneTemplate
|
||||
}
|
||||
|
|
@ -118,13 +113,6 @@ func (t FileuploadPoolTemplate) setModelRels(o *models.FileuploadPool) {
|
|||
o.R.CSVFileCSV = rel
|
||||
}
|
||||
|
||||
if t.r.Organization != nil {
|
||||
rel := t.r.Organization.o.Build()
|
||||
rel.R.Pools = append(rel.R.Pools, o)
|
||||
o.OrganizationID = rel.ID // h2
|
||||
o.R.Organization = rel
|
||||
}
|
||||
|
||||
if t.r.PropertyOwnerPhoneE164Phone != nil {
|
||||
rel := t.r.PropertyOwnerPhoneE164Phone.o.Build()
|
||||
rel.R.PropertyOwnerPhoneE164Pools = append(rel.R.PropertyOwnerPhoneE164Pools, o)
|
||||
|
|
@ -201,10 +189,6 @@ func (o FileuploadPoolTemplate) BuildSetter() *models.FileuploadPoolSetter {
|
|||
val := o.Notes()
|
||||
m.Notes = omit.From(val)
|
||||
}
|
||||
if o.OrganizationID != nil {
|
||||
val := o.OrganizationID()
|
||||
m.OrganizationID = omit.From(val)
|
||||
}
|
||||
if o.PropertyOwnerName != nil {
|
||||
val := o.PropertyOwnerName()
|
||||
m.PropertyOwnerName = omit.From(val)
|
||||
|
|
@ -305,9 +289,6 @@ func (o FileuploadPoolTemplate) Build() *models.FileuploadPool {
|
|||
if o.Notes != nil {
|
||||
m.Notes = o.Notes()
|
||||
}
|
||||
if o.OrganizationID != nil {
|
||||
m.OrganizationID = o.OrganizationID()
|
||||
}
|
||||
if o.PropertyOwnerName != nil {
|
||||
m.PropertyOwnerName = o.PropertyOwnerName()
|
||||
}
|
||||
|
|
@ -395,10 +376,6 @@ func ensureCreatableFileuploadPool(m *models.FileuploadPoolSetter) {
|
|||
val := random_string(nil)
|
||||
m.Notes = omit.From(val)
|
||||
}
|
||||
if !(m.OrganizationID.IsValue()) {
|
||||
val := random_int32(nil)
|
||||
m.OrganizationID = omit.From(val)
|
||||
}
|
||||
if !(m.PropertyOwnerName.IsValue()) {
|
||||
val := random_string(nil)
|
||||
m.PropertyOwnerName = omit.From(val)
|
||||
|
|
@ -437,12 +414,12 @@ func (o *FileuploadPoolTemplate) insertOptRels(ctx context.Context, exec bob.Exe
|
|||
if o.r.PropertyOwnerPhoneE164Phone.o.alreadyPersisted {
|
||||
m.R.PropertyOwnerPhoneE164Phone = o.r.PropertyOwnerPhoneE164Phone.o.Build()
|
||||
} else {
|
||||
var rel3 *models.CommsPhone
|
||||
rel3, err = o.r.PropertyOwnerPhoneE164Phone.o.Create(ctx, exec)
|
||||
var rel2 *models.CommsPhone
|
||||
rel2, err = o.r.PropertyOwnerPhoneE164Phone.o.Create(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.AttachPropertyOwnerPhoneE164Phone(ctx, exec, rel3)
|
||||
err = m.AttachPropertyOwnerPhoneE164Phone(ctx, exec, rel2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -456,12 +433,12 @@ func (o *FileuploadPoolTemplate) insertOptRels(ctx context.Context, exec bob.Exe
|
|||
if o.r.ResidentPhoneE164Phone.o.alreadyPersisted {
|
||||
m.R.ResidentPhoneE164Phone = o.r.ResidentPhoneE164Phone.o.Build()
|
||||
} else {
|
||||
var rel4 *models.CommsPhone
|
||||
rel4, err = o.r.ResidentPhoneE164Phone.o.Create(ctx, exec)
|
||||
var rel3 *models.CommsPhone
|
||||
rel3, err = o.r.ResidentPhoneE164Phone.o.Create(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.AttachResidentPhoneE164Phone(ctx, exec, rel4)
|
||||
err = m.AttachResidentPhoneE164Phone(ctx, exec, rel3)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -513,23 +490,6 @@ func (o *FileuploadPoolTemplate) Create(ctx context.Context, exec bob.Executor)
|
|||
|
||||
opt.CSVFile = omit.From(rel1.FileID)
|
||||
|
||||
if o.r.Organization == nil {
|
||||
FileuploadPoolMods.WithNewOrganization().Apply(ctx, o)
|
||||
}
|
||||
|
||||
var rel2 *models.Organization
|
||||
|
||||
if o.r.Organization.o.alreadyPersisted {
|
||||
rel2 = o.r.Organization.o.Build()
|
||||
} else {
|
||||
rel2, err = o.r.Organization.o.Create(ctx, exec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
opt.OrganizationID = omit.From(rel2.ID)
|
||||
|
||||
m, err := models.FileuploadPools.Insert(opt).One(ctx, exec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -537,7 +497,6 @@ func (o *FileuploadPoolTemplate) Create(ctx context.Context, exec bob.Executor)
|
|||
|
||||
m.R.CreatorUser = rel0
|
||||
m.R.CSVFileCSV = rel1
|
||||
m.R.Organization = rel2
|
||||
|
||||
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -630,7 +589,6 @@ func (m fileuploadPoolMods) RandomizeAllColumns(f *faker.Faker) FileuploadPoolMo
|
|||
FileuploadPoolMods.RandomIsInDistrict(f),
|
||||
FileuploadPoolMods.RandomIsNew(f),
|
||||
FileuploadPoolMods.RandomNotes(f),
|
||||
FileuploadPoolMods.RandomOrganizationID(f),
|
||||
FileuploadPoolMods.RandomPropertyOwnerName(f),
|
||||
FileuploadPoolMods.RandomPropertyOwnerPhoneE164(f),
|
||||
FileuploadPoolMods.RandomResidentOwned(f),
|
||||
|
|
@ -1143,37 +1101,6 @@ func (m fileuploadPoolMods) RandomNotes(f *faker.Faker) FileuploadPoolMod {
|
|||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m fileuploadPoolMods) OrganizationID(val int32) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(_ context.Context, o *FileuploadPoolTemplate) {
|
||||
o.OrganizationID = func() int32 { return val }
|
||||
})
|
||||
}
|
||||
|
||||
// Set the Column from the function
|
||||
func (m fileuploadPoolMods) OrganizationIDFunc(f func() int32) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(_ context.Context, o *FileuploadPoolTemplate) {
|
||||
o.OrganizationID = f
|
||||
})
|
||||
}
|
||||
|
||||
// Clear any values for the column
|
||||
func (m fileuploadPoolMods) UnsetOrganizationID() FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(_ context.Context, o *FileuploadPoolTemplate) {
|
||||
o.OrganizationID = nil
|
||||
})
|
||||
}
|
||||
|
||||
// Generates a random value for the column using the given faker
|
||||
// if faker is nil, a default faker is used
|
||||
func (m fileuploadPoolMods) RandomOrganizationID(f *faker.Faker) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(_ context.Context, o *FileuploadPoolTemplate) {
|
||||
o.OrganizationID = func() int32 {
|
||||
return random_int32(f)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Set the model columns to this value
|
||||
func (m fileuploadPoolMods) PropertyOwnerName(val string) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(_ context.Context, o *FileuploadPoolTemplate) {
|
||||
|
|
@ -1535,11 +1462,6 @@ func (m fileuploadPoolMods) WithParentsCascading() FileuploadPoolMod {
|
|||
related := o.f.NewFileuploadCSVWithContext(ctx, FileuploadCSVMods.WithParentsCascading())
|
||||
m.WithCSVFileCSV(related).Apply(ctx, o)
|
||||
}
|
||||
{
|
||||
|
||||
related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
|
||||
m.WithOrganization(related).Apply(ctx, o)
|
||||
}
|
||||
{
|
||||
|
||||
related := o.f.NewCommsPhoneWithContext(ctx, CommsPhoneMods.WithParentsCascading())
|
||||
|
|
@ -1613,36 +1535,6 @@ func (m fileuploadPoolMods) WithoutCSVFileCSV() FileuploadPoolMod {
|
|||
})
|
||||
}
|
||||
|
||||
func (m fileuploadPoolMods) WithOrganization(rel *OrganizationTemplate) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(ctx context.Context, o *FileuploadPoolTemplate) {
|
||||
o.r.Organization = &fileuploadPoolROrganizationR{
|
||||
o: rel,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m fileuploadPoolMods) WithNewOrganization(mods ...OrganizationMod) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(ctx context.Context, o *FileuploadPoolTemplate) {
|
||||
related := o.f.NewOrganizationWithContext(ctx, mods...)
|
||||
|
||||
m.WithOrganization(related).Apply(ctx, o)
|
||||
})
|
||||
}
|
||||
|
||||
func (m fileuploadPoolMods) WithExistingOrganization(em *models.Organization) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(ctx context.Context, o *FileuploadPoolTemplate) {
|
||||
o.r.Organization = &fileuploadPoolROrganizationR{
|
||||
o: o.f.FromExistingOrganization(em),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m fileuploadPoolMods) WithoutOrganization() FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(ctx context.Context, o *FileuploadPoolTemplate) {
|
||||
o.r.Organization = nil
|
||||
})
|
||||
}
|
||||
|
||||
func (m fileuploadPoolMods) WithPropertyOwnerPhoneE164Phone(rel *CommsPhoneTemplate) FileuploadPoolMod {
|
||||
return FileuploadPoolModFunc(func(ctx context.Context, o *FileuploadPoolTemplate) {
|
||||
o.r.PropertyOwnerPhoneE164Phone = &fileuploadPoolRPropertyOwnerPhoneE164PhoneR{
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ type organizationR struct {
|
|||
Zones2s []*organizationRZones2sR
|
||||
FieldseekerSyncs []*organizationRFieldseekerSyncsR
|
||||
Files []*organizationRFilesR
|
||||
Pools []*organizationRPoolsR
|
||||
H3Aggregations []*organizationRH3AggregationsR
|
||||
NoteAudios []*organizationRNoteAudiosR
|
||||
NoteImages []*organizationRNoteImagesR
|
||||
|
|
@ -261,10 +260,6 @@ type organizationRFilesR struct {
|
|||
number int
|
||||
o *FileuploadFileTemplate
|
||||
}
|
||||
type organizationRPoolsR struct {
|
||||
number int
|
||||
o *FileuploadPoolTemplate
|
||||
}
|
||||
type organizationRH3AggregationsR struct {
|
||||
number int
|
||||
o *H3AggregationTemplate
|
||||
|
|
@ -754,19 +749,6 @@ func (t OrganizationTemplate) setModelRels(o *models.Organization) {
|
|||
o.R.Files = rel
|
||||
}
|
||||
|
||||
if t.r.Pools != nil {
|
||||
rel := models.FileuploadPoolSlice{}
|
||||
for _, r := range t.r.Pools {
|
||||
related := r.o.BuildMany(r.number)
|
||||
for _, rel := range related {
|
||||
rel.OrganizationID = o.ID // h2
|
||||
rel.R.Organization = o
|
||||
}
|
||||
rel = append(rel, related...)
|
||||
}
|
||||
o.R.Pools = rel
|
||||
}
|
||||
|
||||
if t.r.H3Aggregations != nil {
|
||||
rel := models.H3AggregationSlice{}
|
||||
for _, r := range t.r.H3Aggregations {
|
||||
|
|
@ -1809,26 +1791,6 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
}
|
||||
}
|
||||
|
||||
isPoolsDone, _ := organizationRelPoolsCtx.Value(ctx)
|
||||
if !isPoolsDone && o.r.Pools != nil {
|
||||
ctx = organizationRelPoolsCtx.WithValue(ctx, true)
|
||||
for _, r := range o.r.Pools {
|
||||
if r.o.alreadyPersisted {
|
||||
m.R.Pools = append(m.R.Pools, r.o.Build())
|
||||
} else {
|
||||
rel34, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachPools(ctx, exec, rel34...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isH3AggregationsDone, _ := organizationRelH3AggregationsCtx.Value(ctx)
|
||||
if !isH3AggregationsDone && o.r.H3Aggregations != nil {
|
||||
ctx = organizationRelH3AggregationsCtx.WithValue(ctx, true)
|
||||
|
|
@ -1836,12 +1798,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.H3Aggregations = append(m.R.H3Aggregations, r.o.Build())
|
||||
} else {
|
||||
rel35, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel34, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachH3Aggregations(ctx, exec, rel35...)
|
||||
err = m.AttachH3Aggregations(ctx, exec, rel34...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1856,12 +1818,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.NoteAudios = append(m.R.NoteAudios, r.o.Build())
|
||||
} else {
|
||||
rel36, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel35, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachNoteAudios(ctx, exec, rel36...)
|
||||
err = m.AttachNoteAudios(ctx, exec, rel35...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1876,12 +1838,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.NoteImages = append(m.R.NoteImages, r.o.Build())
|
||||
} else {
|
||||
rel37, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel36, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachNoteImages(ctx, exec, rel37...)
|
||||
err = m.AttachNoteImages(ctx, exec, rel36...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1895,12 +1857,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if o.r.ArcgisAccountAccount.o.alreadyPersisted {
|
||||
m.R.ArcgisAccountAccount = o.r.ArcgisAccountAccount.o.Build()
|
||||
} else {
|
||||
var rel38 *models.ArcgisAccount
|
||||
rel38, err = o.r.ArcgisAccountAccount.o.Create(ctx, exec)
|
||||
var rel37 *models.ArcgisAccount
|
||||
rel37, err = o.r.ArcgisAccountAccount.o.Create(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.AttachArcgisAccountAccount(ctx, exec, rel38)
|
||||
err = m.AttachArcgisAccountAccount(ctx, exec, rel37)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1914,12 +1876,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if o.r.FieldseekerServiceFeatureItemServiceFeature.o.alreadyPersisted {
|
||||
m.R.FieldseekerServiceFeatureItemServiceFeature = o.r.FieldseekerServiceFeatureItemServiceFeature.o.Build()
|
||||
} else {
|
||||
var rel39 *models.ArcgisServiceFeature
|
||||
rel39, err = o.r.FieldseekerServiceFeatureItemServiceFeature.o.Create(ctx, exec)
|
||||
var rel38 *models.ArcgisServiceFeature
|
||||
rel38, err = o.r.FieldseekerServiceFeatureItemServiceFeature.o.Create(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = m.AttachFieldseekerServiceFeatureItemServiceFeature(ctx, exec, rel39)
|
||||
err = m.AttachFieldseekerServiceFeatureItemServiceFeature(ctx, exec, rel38)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1934,12 +1896,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.Nuisances = append(m.R.Nuisances, r.o.Build())
|
||||
} else {
|
||||
rel40, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel39, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachNuisances(ctx, exec, rel40...)
|
||||
err = m.AttachNuisances(ctx, exec, rel39...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1954,12 +1916,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.PublicreportPool = append(m.R.PublicreportPool, r.o.Build())
|
||||
} else {
|
||||
rel41, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel40, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachPublicreportPool(ctx, exec, rel41...)
|
||||
err = m.AttachPublicreportPool(ctx, exec, rel40...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1974,12 +1936,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.Quicks = append(m.R.Quicks, r.o.Build())
|
||||
} else {
|
||||
rel42, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel41, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachQuicks(ctx, exec, rel42...)
|
||||
err = m.AttachQuicks(ctx, exec, rel41...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -1994,12 +1956,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.Signals = append(m.R.Signals, r.o.Build())
|
||||
} else {
|
||||
rel43, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel42, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachSignals(ctx, exec, rel43...)
|
||||
err = m.AttachSignals(ctx, exec, rel42...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -2014,12 +1976,12 @@ func (o *OrganizationTemplate) insertOptRels(ctx context.Context, exec bob.Execu
|
|||
if r.o.alreadyPersisted {
|
||||
m.R.User = append(m.R.User, r.o.Build())
|
||||
} else {
|
||||
rel44, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
rel43, err := r.o.CreateMany(ctx, exec, r.number)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = m.AttachUser(ctx, exec, rel44...)
|
||||
err = m.AttachUser(ctx, exec, rel43...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -5517,54 +5479,6 @@ func (m organizationMods) WithoutFiles() OrganizationMod {
|
|||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) WithPools(number int, related *FileuploadPoolTemplate) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
o.r.Pools = []*organizationRPoolsR{{
|
||||
number: number,
|
||||
o: related,
|
||||
}}
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) WithNewPools(number int, mods ...FileuploadPoolMod) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
related := o.f.NewFileuploadPoolWithContext(ctx, mods...)
|
||||
m.WithPools(number, related).Apply(ctx, o)
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) AddPools(number int, related *FileuploadPoolTemplate) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
o.r.Pools = append(o.r.Pools, &organizationRPoolsR{
|
||||
number: number,
|
||||
o: related,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) AddNewPools(number int, mods ...FileuploadPoolMod) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
related := o.f.NewFileuploadPoolWithContext(ctx, mods...)
|
||||
m.AddPools(number, related).Apply(ctx, o)
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) AddExistingPools(existingModels ...*models.FileuploadPool) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
for _, em := range existingModels {
|
||||
o.r.Pools = append(o.r.Pools, &organizationRPoolsR{
|
||||
o: o.f.FromExistingFileuploadPool(em),
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) WithoutPools() OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
o.r.Pools = nil
|
||||
})
|
||||
}
|
||||
|
||||
func (m organizationMods) WithH3Aggregations(number int, related *H3AggregationTemplate) OrganizationMod {
|
||||
return OrganizationModFunc(func(ctx context.Context, o *OrganizationTemplate) {
|
||||
o.r.H3Aggregations = []*organizationRH3AggregationsR{{
|
||||
|
|
|
|||
4
db/migrations/00083_drop_pool_organization_id.sql
Normal file
4
db/migrations/00083_drop_pool_organization_id.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- +goose Up
|
||||
ALTER TABLE fileupload.pool DROP COLUMN organization_id;
|
||||
-- +goose Down
|
||||
ALTER TABLE fileupload.pool ADD COLUMN organization_id INTEGER REFERENCES organization(id);
|
||||
|
|
@ -41,7 +41,6 @@ type FileuploadPool struct {
|
|||
IsInDistrict bool `db:"is_in_district" `
|
||||
IsNew bool `db:"is_new" `
|
||||
Notes string `db:"notes" `
|
||||
OrganizationID int32 `db:"organization_id" `
|
||||
PropertyOwnerName string `db:"property_owner_name" `
|
||||
PropertyOwnerPhoneE164 null.Val[string] `db:"property_owner_phone_e164" `
|
||||
ResidentOwned null.Val[bool] `db:"resident_owned" `
|
||||
|
|
@ -69,7 +68,6 @@ type FileuploadPoolsQuery = *psql.ViewQuery[*FileuploadPool, FileuploadPoolSlice
|
|||
type fileuploadPoolR struct {
|
||||
CreatorUser *User // fileupload.pool.pool_creator_id_fkey
|
||||
CSVFileCSV *FileuploadCSV // fileupload.pool.pool_csv_file_fkey
|
||||
Organization *Organization // fileupload.pool.pool_organization_id_fkey
|
||||
PropertyOwnerPhoneE164Phone *CommsPhone // fileupload.pool.pool_property_owner_phone_e164_fkey
|
||||
ResidentPhoneE164Phone *CommsPhone // fileupload.pool.pool_resident_phone_e164_fkey
|
||||
}
|
||||
|
|
@ -77,7 +75,7 @@ type fileuploadPoolR struct {
|
|||
func buildFileuploadPoolColumns(alias string) fileuploadPoolColumns {
|
||||
return fileuploadPoolColumns{
|
||||
ColumnsExpr: expr.NewColumnsExpr(
|
||||
"address_postal_code", "address_street", "committed", "condition", "created", "creator_id", "csv_file", "deleted", "geom", "h3cell", "id", "is_in_district", "is_new", "notes", "organization_id", "property_owner_name", "property_owner_phone_e164", "resident_owned", "resident_phone_e164", "line_number", "tags", "address_number", "address_locality", "address_region",
|
||||
"address_postal_code", "address_street", "committed", "condition", "created", "creator_id", "csv_file", "deleted", "geom", "h3cell", "id", "is_in_district", "is_new", "notes", "property_owner_name", "property_owner_phone_e164", "resident_owned", "resident_phone_e164", "line_number", "tags", "address_number", "address_locality", "address_region",
|
||||
).WithParent("fileupload.pool"),
|
||||
tableAlias: alias,
|
||||
AddressPostalCode: psql.Quote(alias, "address_postal_code"),
|
||||
|
|
@ -94,7 +92,6 @@ func buildFileuploadPoolColumns(alias string) fileuploadPoolColumns {
|
|||
IsInDistrict: psql.Quote(alias, "is_in_district"),
|
||||
IsNew: psql.Quote(alias, "is_new"),
|
||||
Notes: psql.Quote(alias, "notes"),
|
||||
OrganizationID: psql.Quote(alias, "organization_id"),
|
||||
PropertyOwnerName: psql.Quote(alias, "property_owner_name"),
|
||||
PropertyOwnerPhoneE164: psql.Quote(alias, "property_owner_phone_e164"),
|
||||
ResidentOwned: psql.Quote(alias, "resident_owned"),
|
||||
|
|
@ -124,7 +121,6 @@ type fileuploadPoolColumns struct {
|
|||
IsInDistrict psql.Expression
|
||||
IsNew psql.Expression
|
||||
Notes psql.Expression
|
||||
OrganizationID psql.Expression
|
||||
PropertyOwnerName psql.Expression
|
||||
PropertyOwnerPhoneE164 psql.Expression
|
||||
ResidentOwned psql.Expression
|
||||
|
|
@ -162,7 +158,6 @@ type FileuploadPoolSetter struct {
|
|||
IsInDistrict omit.Val[bool] `db:"is_in_district" `
|
||||
IsNew omit.Val[bool] `db:"is_new" `
|
||||
Notes omit.Val[string] `db:"notes" `
|
||||
OrganizationID omit.Val[int32] `db:"organization_id" `
|
||||
PropertyOwnerName omit.Val[string] `db:"property_owner_name" `
|
||||
PropertyOwnerPhoneE164 omitnull.Val[string] `db:"property_owner_phone_e164" `
|
||||
ResidentOwned omitnull.Val[bool] `db:"resident_owned" `
|
||||
|
|
@ -175,7 +170,7 @@ type FileuploadPoolSetter struct {
|
|||
}
|
||||
|
||||
func (s FileuploadPoolSetter) SetColumns() []string {
|
||||
vals := make([]string, 0, 24)
|
||||
vals := make([]string, 0, 23)
|
||||
if s.AddressPostalCode.IsValue() {
|
||||
vals = append(vals, "address_postal_code")
|
||||
}
|
||||
|
|
@ -218,9 +213,6 @@ func (s FileuploadPoolSetter) SetColumns() []string {
|
|||
if s.Notes.IsValue() {
|
||||
vals = append(vals, "notes")
|
||||
}
|
||||
if s.OrganizationID.IsValue() {
|
||||
vals = append(vals, "organization_id")
|
||||
}
|
||||
if s.PropertyOwnerName.IsValue() {
|
||||
vals = append(vals, "property_owner_name")
|
||||
}
|
||||
|
|
@ -294,9 +286,6 @@ func (s FileuploadPoolSetter) Overwrite(t *FileuploadPool) {
|
|||
if s.Notes.IsValue() {
|
||||
t.Notes = s.Notes.MustGet()
|
||||
}
|
||||
if s.OrganizationID.IsValue() {
|
||||
t.OrganizationID = s.OrganizationID.MustGet()
|
||||
}
|
||||
if s.PropertyOwnerName.IsValue() {
|
||||
t.PropertyOwnerName = s.PropertyOwnerName.MustGet()
|
||||
}
|
||||
|
|
@ -332,7 +321,7 @@ func (s *FileuploadPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
})
|
||||
|
||||
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
||||
vals := make([]bob.Expression, 24)
|
||||
vals := make([]bob.Expression, 23)
|
||||
if s.AddressPostalCode.IsValue() {
|
||||
vals[0] = psql.Arg(s.AddressPostalCode.MustGet())
|
||||
} else {
|
||||
|
|
@ -417,66 +406,60 @@ func (s *FileuploadPoolSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[13] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.OrganizationID.IsValue() {
|
||||
vals[14] = psql.Arg(s.OrganizationID.MustGet())
|
||||
if s.PropertyOwnerName.IsValue() {
|
||||
vals[14] = psql.Arg(s.PropertyOwnerName.MustGet())
|
||||
} else {
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.PropertyOwnerName.IsValue() {
|
||||
vals[15] = psql.Arg(s.PropertyOwnerName.MustGet())
|
||||
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
||||
vals[15] = psql.Arg(s.PropertyOwnerPhoneE164.MustGetNull())
|
||||
} else {
|
||||
vals[15] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.PropertyOwnerPhoneE164.IsUnset() {
|
||||
vals[16] = psql.Arg(s.PropertyOwnerPhoneE164.MustGetNull())
|
||||
if !s.ResidentOwned.IsUnset() {
|
||||
vals[16] = psql.Arg(s.ResidentOwned.MustGetNull())
|
||||
} else {
|
||||
vals[16] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ResidentOwned.IsUnset() {
|
||||
vals[17] = psql.Arg(s.ResidentOwned.MustGetNull())
|
||||
if !s.ResidentPhoneE164.IsUnset() {
|
||||
vals[17] = psql.Arg(s.ResidentPhoneE164.MustGetNull())
|
||||
} else {
|
||||
vals[17] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if !s.ResidentPhoneE164.IsUnset() {
|
||||
vals[18] = psql.Arg(s.ResidentPhoneE164.MustGetNull())
|
||||
if s.LineNumber.IsValue() {
|
||||
vals[18] = psql.Arg(s.LineNumber.MustGet())
|
||||
} else {
|
||||
vals[18] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.LineNumber.IsValue() {
|
||||
vals[19] = psql.Arg(s.LineNumber.MustGet())
|
||||
if s.Tags.IsValue() {
|
||||
vals[19] = psql.Arg(s.Tags.MustGet())
|
||||
} else {
|
||||
vals[19] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.Tags.IsValue() {
|
||||
vals[20] = psql.Arg(s.Tags.MustGet())
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals[20] = psql.Arg(s.AddressNumber.MustGet())
|
||||
} else {
|
||||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressNumber.IsValue() {
|
||||
vals[21] = psql.Arg(s.AddressNumber.MustGet())
|
||||
if s.AddressLocality.IsValue() {
|
||||
vals[21] = psql.Arg(s.AddressLocality.MustGet())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressLocality.IsValue() {
|
||||
vals[22] = psql.Arg(s.AddressLocality.MustGet())
|
||||
if s.AddressRegion.IsValue() {
|
||||
vals[22] = psql.Arg(s.AddressRegion.MustGet())
|
||||
} else {
|
||||
vals[22] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.AddressRegion.IsValue() {
|
||||
vals[23] = psql.Arg(s.AddressRegion.MustGet())
|
||||
} else {
|
||||
vals[23] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
}
|
||||
|
|
@ -486,7 +469,7 @@ func (s FileuploadPoolSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|||
}
|
||||
|
||||
func (s FileuploadPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
||||
exprs := make([]bob.Expression, 0, 24)
|
||||
exprs := make([]bob.Expression, 0, 23)
|
||||
|
||||
if s.AddressPostalCode.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
|
|
@ -586,13 +569,6 @@ func (s FileuploadPoolSetter) Expressions(prefix ...string) []bob.Expression {
|
|||
}})
|
||||
}
|
||||
|
||||
if s.OrganizationID.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "organization_id")...),
|
||||
psql.Arg(s.OrganizationID),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.PropertyOwnerName.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "property_owner_name")...),
|
||||
|
|
@ -930,30 +906,6 @@ func (os FileuploadPoolSlice) CSVFileCSV(mods ...bob.Mod[*dialect.SelectQuery])
|
|||
)...)
|
||||
}
|
||||
|
||||
// Organization starts a query for related objects on organization
|
||||
func (o *FileuploadPool) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
||||
return Organizations.Query(append(mods,
|
||||
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os FileuploadPoolSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
||||
pkOrganizationID := make(pgtypes.Array[int32], 0, len(os))
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
|
||||
}
|
||||
PKArgExpr := psql.Select(sm.Columns(
|
||||
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
|
||||
))
|
||||
|
||||
return Organizations.Query(append(mods,
|
||||
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// PropertyOwnerPhoneE164Phone starts a query for related objects on comms.phone
|
||||
func (o *FileuploadPool) PropertyOwnerPhoneE164Phone(mods ...bob.Mod[*dialect.SelectQuery]) CommsPhonesQuery {
|
||||
return CommsPhones.Query(append(mods,
|
||||
|
|
@ -1098,54 +1050,6 @@ func (fileuploadPool0 *FileuploadPool) AttachCSVFileCSV(ctx context.Context, exe
|
|||
return nil
|
||||
}
|
||||
|
||||
func attachFileuploadPoolOrganization0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, organization1 *Organization) (*FileuploadPool, error) {
|
||||
setter := &FileuploadPoolSetter{
|
||||
OrganizationID: omit.From(organization1.ID),
|
||||
}
|
||||
|
||||
err := fileuploadPool0.Update(ctx, exec, setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachFileuploadPoolOrganization0: %w", err)
|
||||
}
|
||||
|
||||
return fileuploadPool0, nil
|
||||
}
|
||||
|
||||
func (fileuploadPool0 *FileuploadPool) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
|
||||
var err error
|
||||
|
||||
organization1, err := Organizations.Insert(related).One(ctx, exec)
|
||||
if err != nil {
|
||||
return fmt.Errorf("inserting related objects: %w", err)
|
||||
}
|
||||
|
||||
_, err = attachFileuploadPoolOrganization0(ctx, exec, 1, fileuploadPool0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileuploadPool0.R.Organization = organization1
|
||||
|
||||
organization1.R.Pools = append(organization1.R.Pools, fileuploadPool0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fileuploadPool0 *FileuploadPool) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
||||
var err error
|
||||
|
||||
_, err = attachFileuploadPoolOrganization0(ctx, exec, 1, fileuploadPool0, organization1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileuploadPool0.R.Organization = organization1
|
||||
|
||||
organization1.R.Pools = append(organization1.R.Pools, fileuploadPool0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func attachFileuploadPoolPropertyOwnerPhoneE164Phone0(ctx context.Context, exec bob.Executor, count int, fileuploadPool0 *FileuploadPool, commsPhone1 *CommsPhone) (*FileuploadPool, error) {
|
||||
setter := &FileuploadPoolSetter{
|
||||
PropertyOwnerPhoneE164: omitnull.From(commsPhone1.E164),
|
||||
|
|
@ -1257,7 +1161,6 @@ type fileuploadPoolWhere[Q psql.Filterable] struct {
|
|||
IsInDistrict psql.WhereMod[Q, bool]
|
||||
IsNew psql.WhereMod[Q, bool]
|
||||
Notes psql.WhereMod[Q, string]
|
||||
OrganizationID psql.WhereMod[Q, int32]
|
||||
PropertyOwnerName psql.WhereMod[Q, string]
|
||||
PropertyOwnerPhoneE164 psql.WhereNullMod[Q, string]
|
||||
ResidentOwned psql.WhereNullMod[Q, bool]
|
||||
|
|
@ -1289,7 +1192,6 @@ func buildFileuploadPoolWhere[Q psql.Filterable](cols fileuploadPoolColumns) fil
|
|||
IsInDistrict: psql.Where[Q, bool](cols.IsInDistrict),
|
||||
IsNew: psql.Where[Q, bool](cols.IsNew),
|
||||
Notes: psql.Where[Q, string](cols.Notes),
|
||||
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
|
||||
PropertyOwnerName: psql.Where[Q, string](cols.PropertyOwnerName),
|
||||
PropertyOwnerPhoneE164: psql.WhereNull[Q, string](cols.PropertyOwnerPhoneE164),
|
||||
ResidentOwned: psql.WhereNull[Q, bool](cols.ResidentOwned),
|
||||
|
|
@ -1332,18 +1234,6 @@ func (o *FileuploadPool) Preload(name string, retrieved any) error {
|
|||
rel.R.CSVFilePools = FileuploadPoolSlice{o}
|
||||
}
|
||||
return nil
|
||||
case "Organization":
|
||||
rel, ok := retrieved.(*Organization)
|
||||
if !ok {
|
||||
return fmt.Errorf("fileuploadPool cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Organization = rel
|
||||
|
||||
if rel != nil {
|
||||
rel.R.Pools = FileuploadPoolSlice{o}
|
||||
}
|
||||
return nil
|
||||
case "PropertyOwnerPhoneE164Phone":
|
||||
rel, ok := retrieved.(*CommsPhone)
|
||||
if !ok {
|
||||
|
|
@ -1376,7 +1266,6 @@ func (o *FileuploadPool) Preload(name string, retrieved any) error {
|
|||
type fileuploadPoolPreloader struct {
|
||||
CreatorUser func(...psql.PreloadOption) psql.Preloader
|
||||
CSVFileCSV func(...psql.PreloadOption) psql.Preloader
|
||||
Organization func(...psql.PreloadOption) psql.Preloader
|
||||
PropertyOwnerPhoneE164Phone func(...psql.PreloadOption) psql.Preloader
|
||||
ResidentPhoneE164Phone func(...psql.PreloadOption) psql.Preloader
|
||||
}
|
||||
|
|
@ -1409,19 +1298,6 @@ func buildFileuploadPoolPreloader() fileuploadPoolPreloader {
|
|||
},
|
||||
}, FileuploadCSVS.Columns.Names(), opts...)
|
||||
},
|
||||
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
||||
Name: "Organization",
|
||||
Sides: []psql.PreloadSide{
|
||||
{
|
||||
From: FileuploadPools,
|
||||
To: Organizations,
|
||||
FromColumns: []string{"organization_id"},
|
||||
ToColumns: []string{"id"},
|
||||
},
|
||||
},
|
||||
}, Organizations.Columns.Names(), opts...)
|
||||
},
|
||||
PropertyOwnerPhoneE164Phone: func(opts ...psql.PreloadOption) psql.Preloader {
|
||||
return psql.Preload[*CommsPhone, CommsPhoneSlice](psql.PreloadRel{
|
||||
Name: "PropertyOwnerPhoneE164Phone",
|
||||
|
|
@ -1454,7 +1330,6 @@ func buildFileuploadPoolPreloader() fileuploadPoolPreloader {
|
|||
type fileuploadPoolThenLoader[Q orm.Loadable] struct {
|
||||
CreatorUser func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
CSVFileCSV func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
PropertyOwnerPhoneE164Phone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
ResidentPhoneE164Phone func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
}
|
||||
|
|
@ -1466,9 +1341,6 @@ func buildFileuploadPoolThenLoader[Q orm.Loadable]() fileuploadPoolThenLoader[Q]
|
|||
type CSVFileCSVLoadInterface interface {
|
||||
LoadCSVFileCSV(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type OrganizationLoadInterface interface {
|
||||
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type PropertyOwnerPhoneE164PhoneLoadInterface interface {
|
||||
LoadPropertyOwnerPhoneE164Phone(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -1489,12 +1361,6 @@ func buildFileuploadPoolThenLoader[Q orm.Loadable]() fileuploadPoolThenLoader[Q]
|
|||
return retrieved.LoadCSVFileCSV(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Organization: thenLoadBuilder[Q](
|
||||
"Organization",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadOrganization(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
PropertyOwnerPhoneE164Phone: thenLoadBuilder[Q](
|
||||
"PropertyOwnerPhoneE164Phone",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved PropertyOwnerPhoneE164PhoneLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -1614,58 +1480,6 @@ func (os FileuploadPoolSlice) LoadCSVFileCSV(ctx context.Context, exec bob.Execu
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadOrganization loads the fileuploadPool's Organization into the .R struct
|
||||
func (o *FileuploadPool) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Organization = nil
|
||||
|
||||
related, err := o.Organization(mods...).One(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
related.R.Pools = FileuploadPoolSlice{o}
|
||||
|
||||
o.R.Organization = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadOrganization loads the fileuploadPool's Organization into the .R struct
|
||||
func (os FileuploadPoolSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
organizations, err := os.Organization(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range organizations {
|
||||
|
||||
if !(o.OrganizationID == rel.ID) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.Pools = append(rel.R.Pools, o)
|
||||
|
||||
o.R.Organization = rel
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadPropertyOwnerPhoneE164Phone loads the fileuploadPool's PropertyOwnerPhoneE164Phone into the .R struct
|
||||
func (o *FileuploadPool) LoadPropertyOwnerPhoneE164Phone(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
@ -1780,7 +1594,6 @@ type fileuploadPoolJoins[Q dialect.Joinable] struct {
|
|||
typ string
|
||||
CreatorUser modAs[Q, userColumns]
|
||||
CSVFileCSV modAs[Q, fileuploadCSVColumns]
|
||||
Organization modAs[Q, organizationColumns]
|
||||
PropertyOwnerPhoneE164Phone modAs[Q, commsPhoneColumns]
|
||||
ResidentPhoneE164Phone modAs[Q, commsPhoneColumns]
|
||||
}
|
||||
|
|
@ -1820,20 +1633,6 @@ func buildFileuploadPoolJoins[Q dialect.Joinable](cols fileuploadPoolColumns, ty
|
|||
return mods
|
||||
},
|
||||
},
|
||||
Organization: modAs[Q, organizationColumns]{
|
||||
c: Organizations.Columns,
|
||||
f: func(to organizationColumns) bob.Mod[Q] {
|
||||
mods := make(mods.QueryMods[Q], 0, 1)
|
||||
|
||||
{
|
||||
mods = append(mods, dialect.Join[Q](typ, Organizations.Name().As(to.Alias())).On(
|
||||
to.ID.EQ(cols.OrganizationID),
|
||||
))
|
||||
}
|
||||
|
||||
return mods
|
||||
},
|
||||
},
|
||||
PropertyOwnerPhoneE164Phone: modAs[Q, commsPhoneColumns]{
|
||||
c: CommsPhones.Columns,
|
||||
f: func(to commsPhoneColumns) bob.Mod[Q] {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ type organizationR struct {
|
|||
Zones2s FieldseekerZones2Slice // fieldseeker.zones2.zones2_organization_id_fkey
|
||||
FieldseekerSyncs FieldseekerSyncSlice // fieldseeker_sync.fieldseeker_sync_organization_id_fkey
|
||||
Files FileuploadFileSlice // fileupload.file.file_organization_id_fkey
|
||||
Pools FileuploadPoolSlice // fileupload.pool.pool_organization_id_fkey
|
||||
H3Aggregations H3AggregationSlice // h3_aggregation.h3_aggregation_organization_id_fkey
|
||||
NoteAudios NoteAudioSlice // note_audio.note_audio_organization_id_fkey
|
||||
NoteImages NoteImageSlice // note_image.note_image_organization_id_fkey
|
||||
|
|
@ -1736,30 +1735,6 @@ func (os OrganizationSlice) Files(mods ...bob.Mod[*dialect.SelectQuery]) Fileupl
|
|||
)...)
|
||||
}
|
||||
|
||||
// Pools starts a query for related objects on fileupload.pool
|
||||
func (o *Organization) Pools(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadPoolsQuery {
|
||||
return FileuploadPools.Query(append(mods,
|
||||
sm.Where(FileuploadPools.Columns.OrganizationID.EQ(psql.Arg(o.ID))),
|
||||
)...)
|
||||
}
|
||||
|
||||
func (os OrganizationSlice) Pools(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadPoolsQuery {
|
||||
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 FileuploadPools.Query(append(mods,
|
||||
sm.Where(psql.Group(FileuploadPools.Columns.OrganizationID).OP("IN", PKArgExpr)),
|
||||
)...)
|
||||
}
|
||||
|
||||
// H3Aggregations starts a query for related objects on h3_aggregation
|
||||
func (o *Organization) H3Aggregations(mods ...bob.Mod[*dialect.SelectQuery]) H3AggregationsQuery {
|
||||
return H3Aggregations.Query(append(mods,
|
||||
|
|
@ -4306,74 +4281,6 @@ func (organization0 *Organization) AttachFiles(ctx context.Context, exec bob.Exe
|
|||
return nil
|
||||
}
|
||||
|
||||
func insertOrganizationPools0(ctx context.Context, exec bob.Executor, fileuploadPools1 []*FileuploadPoolSetter, organization0 *Organization) (FileuploadPoolSlice, error) {
|
||||
for i := range fileuploadPools1 {
|
||||
fileuploadPools1[i].OrganizationID = omit.From(organization0.ID)
|
||||
}
|
||||
|
||||
ret, err := FileuploadPools.Insert(bob.ToMods(fileuploadPools1...)).All(ctx, exec)
|
||||
if err != nil {
|
||||
return ret, fmt.Errorf("insertOrganizationPools0: %w", err)
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func attachOrganizationPools0(ctx context.Context, exec bob.Executor, count int, fileuploadPools1 FileuploadPoolSlice, organization0 *Organization) (FileuploadPoolSlice, error) {
|
||||
setter := &FileuploadPoolSetter{
|
||||
OrganizationID: omit.From(organization0.ID),
|
||||
}
|
||||
|
||||
err := fileuploadPools1.UpdateAll(ctx, exec, *setter)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("attachOrganizationPools0: %w", err)
|
||||
}
|
||||
|
||||
return fileuploadPools1, nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) InsertPools(ctx context.Context, exec bob.Executor, related ...*FileuploadPoolSetter) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
fileuploadPools1, err := insertOrganizationPools0(ctx, exec, related, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Pools = append(organization0.R.Pools, fileuploadPools1...)
|
||||
|
||||
for _, rel := range fileuploadPools1 {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (organization0 *Organization) AttachPools(ctx context.Context, exec bob.Executor, related ...*FileuploadPool) error {
|
||||
if len(related) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var err error
|
||||
fileuploadPools1 := FileuploadPoolSlice(related)
|
||||
|
||||
_, err = attachOrganizationPools0(ctx, exec, len(related), fileuploadPools1, organization0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
organization0.R.Pools = append(organization0.R.Pools, fileuploadPools1...)
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = organization0
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func insertOrganizationH3Aggregations0(ctx context.Context, exec bob.Executor, h3Aggregations1 []*H3AggregationSetter, organization0 *Organization) (H3AggregationSlice, error) {
|
||||
for i := range h3Aggregations1 {
|
||||
h3Aggregations1[i].OrganizationID = omit.From(organization0.ID)
|
||||
|
|
@ -5566,20 +5473,6 @@ func (o *Organization) Preload(name string, retrieved any) error {
|
|||
|
||||
o.R.Files = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case "Pools":
|
||||
rels, ok := retrieved.(FileuploadPoolSlice)
|
||||
if !ok {
|
||||
return fmt.Errorf("organization cannot load %T as %q", retrieved, name)
|
||||
}
|
||||
|
||||
o.R.Pools = rels
|
||||
|
||||
for _, rel := range rels {
|
||||
if rel != nil {
|
||||
rel.R.Organization = o
|
||||
|
|
@ -5798,7 +5691,6 @@ type organizationThenLoader[Q orm.Loadable] struct {
|
|||
Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Files func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
|
|
@ -5914,9 +5806,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
type FilesLoadInterface interface {
|
||||
LoadFiles(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type PoolsLoadInterface interface {
|
||||
LoadPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type H3AggregationsLoadInterface interface {
|
||||
LoadH3Aggregations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -6153,12 +6042,6 @@ func buildOrganizationThenLoader[Q orm.Loadable]() organizationThenLoader[Q] {
|
|||
return retrieved.LoadFiles(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Pools: thenLoadBuilder[Q](
|
||||
"Pools",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved PoolsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadPools(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
H3Aggregations: thenLoadBuilder[Q](
|
||||
"H3Aggregations",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved H3AggregationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -8336,67 +8219,6 @@ func (os OrganizationSlice) LoadFiles(ctx context.Context, exec bob.Executor, mo
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadPools loads the organization's Pools into the .R struct
|
||||
func (o *Organization) LoadPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Reset the relationship
|
||||
o.R.Pools = nil
|
||||
|
||||
related, err := o.Pools(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, rel := range related {
|
||||
rel.R.Organization = o
|
||||
}
|
||||
|
||||
o.R.Pools = related
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadPools loads the organization's Pools into the .R struct
|
||||
func (os OrganizationSlice) LoadPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
fileuploadPools, err := os.Pools(mods...).All(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
o.R.Pools = nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if o == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, rel := range fileuploadPools {
|
||||
|
||||
if !(o.ID == rel.OrganizationID) {
|
||||
continue
|
||||
}
|
||||
|
||||
rel.R.Organization = o
|
||||
|
||||
o.R.Pools = append(o.R.Pools, rel)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadH3Aggregations loads the organization's H3Aggregations into the .R struct
|
||||
func (o *Organization) LoadH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
@ -9040,7 +8862,6 @@ type organizationC struct {
|
|||
Zones2s *int64
|
||||
FieldseekerSyncs *int64
|
||||
Files *int64
|
||||
Pools *int64
|
||||
H3Aggregations *int64
|
||||
NoteAudios *int64
|
||||
NoteImages *int64
|
||||
|
|
@ -9126,8 +8947,6 @@ func (o *Organization) PreloadCount(name string, count int64) error {
|
|||
o.C.FieldseekerSyncs = &count
|
||||
case "Files":
|
||||
o.C.Files = &count
|
||||
case "Pools":
|
||||
o.C.Pools = &count
|
||||
case "H3Aggregations":
|
||||
o.C.H3Aggregations = &count
|
||||
case "NoteAudios":
|
||||
|
|
@ -9183,7 +9002,6 @@ type organizationCountPreloader struct {
|
|||
Zones2s func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
Files func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
Pools func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
NoteAudios func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
NoteImages func(...bob.Mod[*dialect.SelectQuery]) psql.Preloader
|
||||
|
|
@ -9780,23 +9598,6 @@ func buildOrganizationCountPreloader() organizationCountPreloader {
|
|||
return psql.Group(psql.Select(subqueryMods...).Expression)
|
||||
})
|
||||
},
|
||||
Pools: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
|
||||
return countPreloader[*Organization]("Pools", func(parent string) bob.Expression {
|
||||
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
|
||||
if parent == "" {
|
||||
parent = Organizations.Alias()
|
||||
}
|
||||
|
||||
subqueryMods := []bob.Mod[*dialect.SelectQuery]{
|
||||
sm.Columns(psql.Raw("count(*)")),
|
||||
|
||||
sm.From(FileuploadPools.Name()),
|
||||
sm.Where(psql.Quote(FileuploadPools.Alias(), "organization_id").EQ(psql.Quote(parent, "id"))),
|
||||
}
|
||||
subqueryMods = append(subqueryMods, mods...)
|
||||
return psql.Group(psql.Select(subqueryMods...).Expression)
|
||||
})
|
||||
},
|
||||
H3Aggregations: func(mods ...bob.Mod[*dialect.SelectQuery]) psql.Preloader {
|
||||
return countPreloader[*Organization]("H3Aggregations", func(parent string) bob.Expression {
|
||||
// Build a correlated subquery: (SELECT COUNT(*) FROM related WHERE fk = parent.pk)
|
||||
|
|
@ -9971,7 +9772,6 @@ type organizationCountThenLoader[Q orm.Loadable] struct {
|
|||
Zones2s func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
FieldseekerSyncs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Files func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
Pools func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
H3Aggregations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
NoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
||||
|
|
@ -10085,9 +9885,6 @@ func buildOrganizationCountThenLoader[Q orm.Loadable]() organizationCountThenLoa
|
|||
type FilesCountInterface interface {
|
||||
LoadCountFiles(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type PoolsCountInterface interface {
|
||||
LoadCountPools(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
type H3AggregationsCountInterface interface {
|
||||
LoadCountH3Aggregations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
||||
}
|
||||
|
|
@ -10318,12 +10115,6 @@ func buildOrganizationCountThenLoader[Q orm.Loadable]() organizationCountThenLoa
|
|||
return retrieved.LoadCountFiles(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
Pools: countThenLoadBuilder[Q](
|
||||
"Pools",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved PoolsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
return retrieved.LoadCountPools(ctx, exec, mods...)
|
||||
},
|
||||
),
|
||||
H3Aggregations: countThenLoadBuilder[Q](
|
||||
"H3Aggregations",
|
||||
func(ctx context.Context, exec bob.Executor, retrieved H3AggregationsCountInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
|
|
@ -11395,36 +11186,6 @@ func (os OrganizationSlice) LoadCountFiles(ctx context.Context, exec bob.Executo
|
|||
return nil
|
||||
}
|
||||
|
||||
// LoadCountPools loads the count of Pools into the C struct
|
||||
func (o *Organization) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
count, err := o.Pools(mods...).Count(ctx, exec)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
o.C.Pools = &count
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCountPools loads the count of Pools for a slice
|
||||
func (os OrganizationSlice) LoadCountPools(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if len(os) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, o := range os {
|
||||
if err := o.LoadCountPools(ctx, exec, mods...); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadCountH3Aggregations loads the count of H3Aggregations into the C struct
|
||||
func (o *Organization) LoadCountH3Aggregations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
||||
if o == nil {
|
||||
|
|
@ -11701,7 +11462,6 @@ type organizationJoins[Q dialect.Joinable] struct {
|
|||
Zones2s modAs[Q, fieldseekerZones2Columns]
|
||||
FieldseekerSyncs modAs[Q, fieldseekerSyncColumns]
|
||||
Files modAs[Q, fileuploadFileColumns]
|
||||
Pools modAs[Q, fileuploadPoolColumns]
|
||||
H3Aggregations modAs[Q, h3AggregationColumns]
|
||||
NoteAudios modAs[Q, noteAudioColumns]
|
||||
NoteImages modAs[Q, noteImageColumns]
|
||||
|
|
@ -12213,20 +11973,6 @@ func buildOrganizationJoins[Q dialect.Joinable](cols organizationColumns, typ st
|
|||
return mods
|
||||
},
|
||||
},
|
||||
Pools: modAs[Q, fileuploadPoolColumns]{
|
||||
c: FileuploadPools.Columns,
|
||||
f: func(to fileuploadPoolColumns) bob.Mod[Q] {
|
||||
mods := make(mods.QueryMods[Q], 0, 1)
|
||||
|
||||
{
|
||||
mods = append(mods, dialect.Join[Q](typ, FileuploadPools.Name().As(to.Alias())).On(
|
||||
to.OrganizationID.EQ(cols.ID),
|
||||
))
|
||||
}
|
||||
|
||||
return mods
|
||||
},
|
||||
},
|
||||
H3Aggregations: modAs[Q, h3AggregationColumns]{
|
||||
c: H3Aggregations.Columns,
|
||||
f: func(to h3AggregationColumns) bob.Mod[Q] {
|
||||
|
|
|
|||
|
|
@ -79,11 +79,14 @@ func JobImport(ctx context.Context, file_id int32, type_ enums.FileuploadCsvtype
|
|||
err = importCSV(ctx, file_id, parseCSVFlyover, processCSVFlyover)
|
||||
}
|
||||
if err != nil {
|
||||
psql.Update(
|
||||
um.Table("fileupload.csv"),
|
||||
_, err := psql.Update(
|
||||
um.Table("fileupload.file"),
|
||||
um.SetCol("status").ToArg("error"),
|
||||
um.Where(psql.Quote("file_id").EQ(psql.Arg(file_id))),
|
||||
um.Where(psql.Quote("id").EQ(psql.Arg(file_id))),
|
||||
).Exec(ctx, db.PGInstance.BobDB)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Failed to set upload to error status")
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ func insertFlyover(ctx context.Context, txn bob.Tx, file *models.FileuploadFile,
|
|||
IsNew: omit.From(true),
|
||||
LineNumber: omit.From(line_number),
|
||||
Notes: omit.From(""),
|
||||
OrganizationID: omit.From(file.OrganizationID),
|
||||
PropertyOwnerName: omit.From(""),
|
||||
PropertyOwnerPhoneE164: omitnull.FromPtr[string](nil),
|
||||
ResidentOwned: omitnull.FromPtr[bool](nil),
|
||||
|
|
@ -217,10 +216,14 @@ func insertFlyover(ctx context.Context, txn bob.Tx, file *models.FileuploadFile,
|
|||
}
|
||||
geom_query := geom.PostgisPointQuery(lng, lat)
|
||||
_, err = psql.Update(
|
||||
um.Table("fileupload.pool"),
|
||||
um.TableAs("fileupload.pool", "pool"),
|
||||
um.SetCol("h3cell").ToArg(cell),
|
||||
um.SetCol("geom").To(geom_query),
|
||||
um.Where(psql.Quote("id").EQ(psql.Arg(flyover.ID))),
|
||||
um.SetCol("is_in_district").To(psql.F("ST_Contains", "org.service_area_geometry", geom_query)),
|
||||
um.From("fileupload.csv").As("csv"),
|
||||
um.InnerJoin("fileupload.file").As("file").OnEQ(psql.Raw("csv.file_id"), psql.Raw("file.id")),
|
||||
um.InnerJoin("organization").As("org").OnEQ(psql.Raw("file.organization_id"), psql.Raw("org.id")),
|
||||
um.Where(psql.Raw("pool.id").EQ(psql.Arg(flyover.ID))),
|
||||
).Exec(ctx, txn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to update flyover geometry: %w", err)
|
||||
|
|
@ -247,7 +250,6 @@ func insertPoollistRow(ctx context.Context, txn bob.Tx, file *models.FileuploadF
|
|||
IsNew: omit.From(true),
|
||||
LineNumber: omit.From(line_number),
|
||||
Notes: omit.From(""),
|
||||
OrganizationID: omit.From(file.OrganizationID),
|
||||
PropertyOwnerName: omit.From(""),
|
||||
PropertyOwnerPhoneE164: omitnull.FromPtr[string](nil),
|
||||
ResidentOwned: omitnull.FromPtr[bool](nil),
|
||||
|
|
|
|||
|
|
@ -205,7 +205,6 @@ func parseCSVPoollist(ctx context.Context, txn bob.Tx, file *models.FileuploadFi
|
|||
IsNew: omit.From(true),
|
||||
LineNumber: omit.From(line_number),
|
||||
Notes: omit.From(""),
|
||||
OrganizationID: omit.From(file.OrganizationID),
|
||||
PropertyOwnerName: omit.From(""),
|
||||
PropertyOwnerPhoneE164: omitnull.FromPtr[string](nil),
|
||||
ResidentOwned: omitnull.FromPtr[bool](nil),
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ import (
|
|||
)
|
||||
|
||||
func PostgisPointQuery(longitude, latitude float64) string {
|
||||
return fmt.Sprintf("ST_GeometryFromText('Point(%f %f)')", longitude, latitude)
|
||||
return fmt.Sprintf("ST_SetSRID(ST_MakePoint(%f, %f), 4326)", longitude, latitude)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue