Emit communication updated events when reports change
Some checks failed
/ golint (push) Failing after 10s
Some checks failed
/ golint (push) Failing after 10s
This commit is contained in:
parent
594bf33b0a
commit
d120ed05f2
4 changed files with 36 additions and 7 deletions
|
|
@ -2,6 +2,8 @@ package public
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"source.gleipnir.technology/Gleipnir/nidus-sync/db"
|
||||
//"source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/public/enum"
|
||||
|
|
@ -31,6 +33,20 @@ func CommunicationsFromOrganization(ctx context.Context, txn db.Ex, org_id int64
|
|||
ORDER_BY(table.Communication.Created.DESC())
|
||||
return db.ExecuteManyTx[model.Communication](ctx, txn, statement)
|
||||
}
|
||||
func CommunicationFromReportID(ctx context.Context, txn db.Ex, report_id int64) (*model.Communication, error) {
|
||||
statement := table.Communication.SELECT(
|
||||
table.Communication.AllColumns,
|
||||
).FROM(table.Communication).
|
||||
WHERE(table.Communication.SourceReportID.EQ(postgres.Int(report_id)))
|
||||
row, err := db.ExecuteOneTx[model.Communication](ctx, txn, statement)
|
||||
if err != nil {
|
||||
if errors.Is(err, db.ErrNoRows) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, fmt.Errorf("query communication from report %d: %w", report_id, err)
|
||||
}
|
||||
return &row, nil
|
||||
}
|
||||
func CommunicationSetStatus(ctx context.Context, txn db.Ex, org_id int64, comm_id int64, status model.Communicationstatus) error {
|
||||
statement := table.Communication.UPDATE().
|
||||
SET(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue