Update storage of reporter in contact
I failed to retrieve the data correctly before as part of the changeover to contact records. Issue: #13
This commit is contained in:
parent
b9f2107c79
commit
e3cc1e99d1
9 changed files with 132 additions and 50 deletions
|
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
"github.com/rs/zerolog/log"
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
|
||||
modelcomms "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/comms/model"
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/public/model"
|
||||
tablepublic "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/public/table"
|
||||
modelpublicreport "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/publicreport/model"
|
||||
|
|
@ -235,18 +234,8 @@ func PublicReportUpdateCompliance(ctx context.Context, public_id string, report_
|
|||
}
|
||||
}
|
||||
if reporter != nil {
|
||||
if report.ReporterContactID == nil {
|
||||
contact := modelcomms.Contact{
|
||||
Created: time.Now(),
|
||||
Name: reporter.Name,
|
||||
OrganizationID: report.OrganizationID,
|
||||
}
|
||||
_, err = querycomms.ContactInsert(ctx, txn, contact)
|
||||
if err != nil {
|
||||
return fmt.Errorf("insert contact: %w", err)
|
||||
}
|
||||
} else if reporter.Name != "" {
|
||||
err = querycomms.ContactUpdateName(ctx, txn, int64(*report.ReporterContactID), reporter.Name)
|
||||
if reporter.Name != "" {
|
||||
err = querycomms.ContactUpdateName(ctx, txn, int64(report.ReporterContactID), reporter.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("update contact: %w", err)
|
||||
}
|
||||
|
|
@ -397,7 +386,7 @@ func publicReportCreate(ctx context.Context, setter_report modelpublicreport.Rep
|
|||
if err != nil {
|
||||
return result, fmt.Errorf("contact empty: %w", err)
|
||||
}
|
||||
setter_report.ReporterContactID = &contact.ID
|
||||
setter_report.ReporterContactID = contact.ID
|
||||
if addr != nil {
|
||||
setter_report.AddressID = addr.ID
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue