Add contacts, rework comms schema
This in a pretty huge change. At a high level we're adding the concept of a 'contact' which is a person or organization that has zero or more contact methods (email, phone). This ended up cascading a number of changes, including critically to the publicreprt schema. In the end it seemed safer to get to the point where I'm confident we aren't using any of the old fields for storing reporter information (though I haven't deleted the columns yet) so I removed the code for defining those columns. At this point I think it's not possible for me to regenerate the bob schema due to the interdependencies between my various schemas, so the migration is well-and-truly happening.
This commit is contained in:
parent
085935fa66
commit
f1fe8b4d2b
46 changed files with 1127 additions and 633 deletions
|
|
@ -53,6 +53,7 @@ func CommunicationRelatedRecords(ctx context.Context, user User, comm *modelpubl
|
|||
// * phone number
|
||||
// * email
|
||||
// * name
|
||||
txn := db.PGInstance.PGXPool
|
||||
result := make([]RelatedRecord, 0)
|
||||
if comm.SourceEmailLogID != nil {
|
||||
email_log, err := querycomms.EmailLogFromID(ctx, int64(*comm.SourceEmailLogID))
|
||||
|
|
@ -71,7 +72,7 @@ func CommunicationRelatedRecords(ctx context.Context, user User, comm *modelpubl
|
|||
})
|
||||
}
|
||||
} else if comm.SourceTextLogID != nil {
|
||||
text_log, err := querycomms.TextLogFromID(ctx, int64(*comm.SourceTextLogID))
|
||||
text_log, err := querycomms.TextLogFromID(ctx, txn, int64(*comm.SourceTextLogID))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("text log from ID: %w", err)
|
||||
}
|
||||
|
|
@ -87,7 +88,7 @@ func CommunicationRelatedRecords(ctx context.Context, user User, comm *modelpubl
|
|||
})
|
||||
}
|
||||
} else if comm.SourceReportID != nil {
|
||||
report, err := querypublicreport.ReportFromID(ctx, int64(*comm.SourceReportID))
|
||||
report, err := querypublicreport.ReportFromID(ctx, txn, int64(*comm.SourceReportID))
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("report from ID: %w", err)
|
||||
}
|
||||
|
|
@ -123,10 +124,12 @@ func CommunicationRelatedRecords(ctx context.Context, user User, comm *modelpubl
|
|||
return result, nil
|
||||
}
|
||||
func CommunicationsForOrganization(ctx context.Context, org_id int64) ([]modelpublic.Communication, error) {
|
||||
return querypublic.CommunicationsFromOrganization(ctx, org_id)
|
||||
txn := db.PGInstance.PGXPool
|
||||
return querypublic.CommunicationsFromOrganization(ctx, txn, org_id)
|
||||
}
|
||||
func CommunicationFromID(ctx context.Context, user User, comm_id int64) (*modelpublic.Communication, error) {
|
||||
comm, err := querypublic.CommunicationFromID(ctx, comm_id)
|
||||
txn := db.PGInstance.PGXPool
|
||||
comm, err := querypublic.CommunicationFromID(ctx, txn, comm_id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue