This commit is contained in:
parent
8b203908a0
commit
725945d95c
22 changed files with 381 additions and 135 deletions
|
|
@ -2,6 +2,7 @@ package comms
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
//"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
|
|
@ -46,14 +47,27 @@ func ContactPhoneUpdateStopMessageID(ctx context.Context, txn db.Ex, e164 string
|
|||
WHERE(table.ContactPhone.E164.EQ(postgres.String(e164)))
|
||||
return db.ExecuteNoneTx(ctx, txn, statement)
|
||||
}
|
||||
|
||||
/*
|
||||
func ContactPhonesFromAddress(ctx context.Context, address string) ([]model.ContactPhone, error) {
|
||||
func ContactPhoneByContactIDs(ctx context.Context, txn db.Ex, contact_ids []int64) (result map[int64][]model.ContactPhone, err error) {
|
||||
sql_ids := make([]postgres.Expression, len(contact_ids))
|
||||
for i, contact_id := range contact_ids {
|
||||
sql_ids[i] = postgres.Int(contact_id)
|
||||
}
|
||||
statement := table.ContactPhone.SELECT(
|
||||
table.ContactPhone.AllColumns,
|
||||
).FROM(table.ContactPhone).
|
||||
WHERE(table.ContactPhone.Source.EQ(postgres.String(address)).OR(
|
||||
table.ContactPhone.Destination.EQ(postgres.String(address))))
|
||||
return db.ExecuteMany[model.ContactPhone](ctx, statement)
|
||||
WHERE(table.ContactPhone.ContactID.IN(sql_ids...))
|
||||
rows, err := db.ExecuteManyTx[model.ContactPhone](ctx, txn, statement)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("query by contact IDs: %w", err)
|
||||
}
|
||||
for _, contact_id := range contact_ids {
|
||||
result[contact_id] = make([]model.ContactPhone, 0)
|
||||
}
|
||||
for _, row := range rows {
|
||||
id := int64(row.ContactID)
|
||||
cur := result[id]
|
||||
cur = append(cur, row)
|
||||
result[id] = cur
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue