Add initial work on getting compliance data for leads
This commit is contained in:
parent
b7d26d5ad7
commit
fa675f293d
3 changed files with 20 additions and 5 deletions
|
|
@ -51,10 +51,16 @@ func leadCreate(ctx context.Context, txn bob.Executor, user User, signal_id int3
|
|||
func leadsBySiteID(ctx context.Context, site_ids []int32) (map[int32][]types.Lead, error) {
|
||||
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.Columns(
|
||||
"id",
|
||||
"site_id",
|
||||
models.Leads.Columns.ID.As("id"),
|
||||
models.Leads.Columns.SiteID.As("site_id"),
|
||||
models.Leads.Columns.Type.As("type"),
|
||||
models.ComplianceReportRequests.Columns.ID.As("compliance_report_request_id"),
|
||||
),
|
||||
sm.From(models.Leads.Name()),
|
||||
sm.LeftJoin(models.ComplianceReportRequests.Name()).OnEQ(
|
||||
models.Leads.Columns.ID,
|
||||
models.ComplianceReportRequests.Columns.LeadID,
|
||||
),
|
||||
sm.From("lead"),
|
||||
sm.Where(
|
||||
models.Leads.Columns.SiteID.EQ(psql.Any(site_ids)),
|
||||
),
|
||||
|
|
|
|||
6
platform/types/compliance_report_request.go
Normal file
6
platform/types/compliance_report_request.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package types
|
||||
|
||||
type ComplianceReportRequest struct {
|
||||
ID int32 `db:"id" json:"id"`
|
||||
PublicID string `db:"public_id" json:"public_id"`
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package types
|
||||
|
||||
type Lead struct {
|
||||
ID int32 `json:"id"`
|
||||
SiteID int32 `json:"site_id"`
|
||||
ComplianceReportRequest *ComplianceReportRequest `db:"-" json:"compliance_report_request"`
|
||||
ComplianceReportRequestID *int32 `db:"compliance_report_request_id" json:"-"`
|
||||
ID int32 `db:"id" json:"id"`
|
||||
SiteID int32 `db:"site_id" json:"site_id"`
|
||||
Type string `db:"type" json:"type"`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue