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
|
|
@ -36,5 +36,5 @@ type Report struct {
|
|||
AddressGid string
|
||||
ClientUUID *uuid.UUID
|
||||
ReporterPhoneCanSms bool
|
||||
ReporterContactID *int32
|
||||
ReporterContactID int32
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,20 @@ func ContactFromID(ctx context.Context, txn db.Ex, id int64) (model.Contact, err
|
|||
WHERE(table.Contact.ID.EQ(postgres.Int(id)))
|
||||
return db.ExecuteOne[model.Contact](ctx, statement)
|
||||
}
|
||||
func ContactsFromIDs(ctx context.Context, txn db.Ex, contact_ids []int64) ([]model.Contact, error) {
|
||||
if len(contact_ids) == 0 {
|
||||
return []model.Contact{}, nil
|
||||
}
|
||||
sql_ids := make([]postgres.Expression, len(contact_ids))
|
||||
for i, contact_id := range contact_ids {
|
||||
sql_ids[i] = postgres.Int(contact_id)
|
||||
}
|
||||
statement := table.Contact.SELECT(
|
||||
table.Contact.AllColumns,
|
||||
).FROM(table.Contact).
|
||||
WHERE(table.Contact.ID.IN(sql_ids...))
|
||||
return db.ExecuteManyTx[model.Contact](ctx, txn, statement)
|
||||
}
|
||||
|
||||
func ContactUpdateName(ctx context.Context, txn db.Ex, id int64, name string) error {
|
||||
statement := table.Contact.UPDATE().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue