Return communication database rows from communication API
This is a pretty big refactor of how communication works to start moving us in the direction we want to go long-term. This adds the new communication row and migrates existing reports to add rows for communication. There's also a bunch of automatic fixes from the new linter. I should have added them separately, but whatever.
This commit is contained in:
parent
a6ce0b7e67
commit
a82732a49c
41 changed files with 365 additions and 220 deletions
32
db/query/publicreport/report.go
Normal file
32
db/query/publicreport/report.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package public
|
||||
|
||||
import (
|
||||
"context"
|
||||
//"time"
|
||||
|
||||
//"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/table"
|
||||
"github.com/go-jet/jet/v2/postgres"
|
||||
)
|
||||
|
||||
/*
|
||||
func CommunicationInsert(ctx context.Context, txn bob.Tx, m *model.Communication) (*model.Communication, error) {
|
||||
m.Created = time.Now()
|
||||
statement := table.Communication.INSERT(table.Communication.MutableColumns).
|
||||
MODEL(m)
|
||||
return db.ExecuteOne[model.Communication](ctx, statement)
|
||||
}
|
||||
*/
|
||||
func PublicReportsFromIDs(ctx context.Context, report_ids []int64) ([]*model.Report, error) {
|
||||
sql_ids := make([]postgres.Expression, len(report_ids))
|
||||
for i, report_id := range report_ids {
|
||||
sql_ids[i] = postgres.Int(report_id)
|
||||
}
|
||||
statement := table.Report.SELECT(
|
||||
table.Report.AllColumns,
|
||||
).FROM(table.Report).
|
||||
WHERE(table.Report.ID.IN(sql_ids...))
|
||||
return db.ExecuteMany[model.Report](ctx, statement)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue