Start work on populating context of communication at API layer
Remove communication stub, it's a performance enhancement.
This commit is contained in:
parent
266004624d
commit
e569bb32b7
9 changed files with 331 additions and 119 deletions
|
|
@ -18,21 +18,6 @@ func CommunicationInsert(ctx context.Context, txn db.Tx, m model.Communication)
|
|||
RETURNING(table.Communication.AllColumns)
|
||||
return db.ExecuteOneTx[model.Communication](ctx, txn, statement)
|
||||
}
|
||||
func CommunicationFromID(ctx context.Context, comm_id int64) (model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.ID.EQ(postgres.Int(comm_id)))
|
||||
return db.ExecuteOne[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationsFromOrganization(ctx context.Context, org_id int64) ([]model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.OrganizationID.EQ(postgres.Int(org_id))).
|
||||
ORDER_BY(table.Communication.Created.DESC())
|
||||
return db.ExecuteMany[model.Communication](ctx, statement)
|
||||
}
|
||||
func CommunicationSetStatus(ctx context.Context, txn db.Tx, org_id int64, comm_id int64, status model.Communicationstatus) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(
|
||||
|
|
@ -51,3 +36,11 @@ func EmailLogFromID(ctx context.Context, id int64) (model.EmailLog, error) {
|
|||
WHERE(table.EmailLog.ID.EQ(postgres.Int(id)))
|
||||
return db.ExecuteOne[model.EmailLog](ctx, statement)
|
||||
}
|
||||
func EmailLogsFromAddress(ctx context.Context, address string) ([]model.EmailLog, error) {
|
||||
statement := table.EmailLog.SELECT(
|
||||
table.EmailLog.AllColumns,
|
||||
).FROM(table.EmailLog).
|
||||
WHERE(table.EmailLog.Source.EQ(postgres.String(address)).OR(
|
||||
table.EmailLog.Destination.EQ(postgres.String(address))))
|
||||
return db.ExecuteMany[model.EmailLog](ctx, statement)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,3 +16,11 @@ func TextLogFromID(ctx context.Context, id int64) (model.TextLog, error) {
|
|||
WHERE(table.TextLog.ID.EQ(postgres.Int(id)))
|
||||
return db.ExecuteOne[model.TextLog](ctx, statement)
|
||||
}
|
||||
func TextLogsFromPhoneNumber(ctx context.Context, number string) ([]model.TextLog, error) {
|
||||
statement := table.TextLog.SELECT(
|
||||
table.TextLog.AllColumns,
|
||||
).FROM(table.TextLog).
|
||||
WHERE(table.TextLog.Source.EQ(postgres.String(number)).OR(
|
||||
table.TextLog.Destination.EQ(postgres.String(number))))
|
||||
return db.ExecuteMany[model.TextLog](ctx, statement)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue