Start wiring together request for a mailer to database
This commit is contained in:
parent
74e24b7de3
commit
2ea47f03f4
14 changed files with 321 additions and 83 deletions
|
|
@ -6,20 +6,33 @@ import (
|
|||
|
||||
//"github.com/aarondl/opt/omit"
|
||||
//"github.com/aarondl/opt/omitnull"
|
||||
//"github.com/Gleipnir-Technology/bob"
|
||||
"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/models"
|
||||
//"github.com/Gleipnir-Technology/nidus-sync/platform/geocode"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
//"github.com/stephenafamo/scan"
|
||||
"github.com/stephenafamo/scan"
|
||||
)
|
||||
|
||||
func featuresBySiteID(ctx context.Context, site_ids []int32) (map[int32][]types.Feature, error) {
|
||||
rows, err := models.Features.Query(
|
||||
sm.Where(models.Features.Columns.SiteID.EQ(psql.Any(site_ids))),
|
||||
).All(ctx, db.PGInstance.BobDB)
|
||||
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
||||
sm.Columns(
|
||||
"feature.id AS id",
|
||||
"feature.site_id AS site_id",
|
||||
"COALESCE(ST_X(feature.location), 0) AS \"location.longitude\"",
|
||||
"COALESCE(ST_Y(feature.location), 0) AS \"location.latitude\"",
|
||||
"'pool' AS type",
|
||||
),
|
||||
sm.From("feature"),
|
||||
sm.InnerJoin("feature_pool").OnEQ(
|
||||
psql.Quote("feature", "id"),
|
||||
psql.Quote("feature_pool", "feature_id"),
|
||||
),
|
||||
sm.Where(
|
||||
models.Features.Columns.ID.EQ(psql.Any(site_ids)),
|
||||
),
|
||||
), scan.StructMapper[types.Feature]())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query features: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue