Return logs on comms public reports
...and start to display them. A bit.
This commit is contained in:
parent
21e8b9880d
commit
685b7456b6
11 changed files with 259 additions and 60 deletions
|
|
@ -5,10 +5,14 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
//"github.com/rs/zerolog/log"
|
||||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
// Send a message from a district to a public reporter within the context of the public report
|
||||
|
|
@ -29,12 +33,35 @@ func ReportSubscriptionConfirmationText(ctx context.Context, txn bob.Executor, d
|
|||
}
|
||||
return err
|
||||
}
|
||||
func reportForTextRecipient(ctx context.Context, txn bob.Executor, destination types.E164) (*models.PublicreportReport, error) {
|
||||
/*return models.ReportText
|
||||
psql.Query(
|
||||
return Addresses.Query(
|
||||
sm.Where(Addresses.Columns.ID.EQ(psql.Arg(IDPK))),
|
||||
).Exists(ctx, exec)
|
||||
*/
|
||||
return nil, nil
|
||||
|
||||
type reportIDs struct {
|
||||
ID int32 `db:"id"`
|
||||
PublicID string `db:"public_id"`
|
||||
OrganizationID int32 `db:"organization_id"`
|
||||
}
|
||||
|
||||
// Get the list of reports that are still open for a particular text message recipient
|
||||
// 'still open' is not well-defined throughout the system, but for now we'll go with
|
||||
// 'not reviewed in any way'.
|
||||
func reportsForTextRecipient(ctx context.Context, txn bob.Executor, destination types.E164) ([]reportIDs, error) {
|
||||
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.Columns(
|
||||
"r.id",
|
||||
"r.public_id",
|
||||
"r.organization_id",
|
||||
),
|
||||
sm.From("comms.text_job").As("t"),
|
||||
sm.InnerJoin("publicreport.report").As("r").OnEQ(
|
||||
psql.Quote("t", "report_id"),
|
||||
psql.Quote("r", "id"),
|
||||
),
|
||||
sm.Where(psql.Quote("t", "report_id").IsNotNull()),
|
||||
sm.Where(psql.Quote("t", "destination").EQ(psql.Arg(destination.PhoneString()))),
|
||||
sm.Where(psql.Quote("r", "status").EQ(psql.Arg(enums.PublicreportReportstatustypeReported))),
|
||||
), scan.StructMapper[reportIDs]())
|
||||
if err != nil {
|
||||
return []reportIDs{}, fmt.Errorf("query reports: %w", err)
|
||||
}
|
||||
|
||||
return rows, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue