2026-03-09 23:26:44 +00:00
|
|
|
package publicreport
|
|
|
|
|
|
|
|
|
|
import (
|
2026-04-12 17:53:25 +00:00
|
|
|
/*
|
2026-03-09 23:26:44 +00:00
|
|
|
"context"
|
|
|
|
|
"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/config"
|
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
|
|
|
|
//"github.com/Gleipnir-Technology/nidus-sync/db/models"
|
|
|
|
|
//"github.com/google/uuid"
|
|
|
|
|
//"github.com/rs/zerolog/log"
|
|
|
|
|
"github.com/stephenafamo/scan"
|
2026-04-12 17:53:25 +00:00
|
|
|
*/
|
2026-03-09 23:26:44 +00:00
|
|
|
)
|
|
|
|
|
|
2026-04-12 17:53:25 +00:00
|
|
|
/*
|
2026-03-21 01:19:36 +00:00
|
|
|
func watersByReportID(ctx context.Context, report_ids []int32) (map[int32]*types.Water, error) {
|
2026-03-18 15:36:20 +00:00
|
|
|
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
2026-03-09 23:26:44 +00:00
|
|
|
sm.Columns(
|
|
|
|
|
"access_comments",
|
|
|
|
|
"access_gate",
|
|
|
|
|
"access_fence",
|
|
|
|
|
"access_locked",
|
|
|
|
|
"access_dog",
|
|
|
|
|
"access_other",
|
|
|
|
|
"comments",
|
|
|
|
|
"has_adult",
|
|
|
|
|
"has_backyard_permission",
|
|
|
|
|
"has_larvae",
|
|
|
|
|
"has_pupae",
|
|
|
|
|
"is_reporter_confidential",
|
|
|
|
|
"is_reporter_owner",
|
|
|
|
|
"owner_email AS \"owner.email\"",
|
|
|
|
|
"owner_name AS \"owner.name\"",
|
|
|
|
|
"owner_phone AS \"owner.phone\"",
|
2026-03-18 15:36:20 +00:00
|
|
|
"report_id",
|
2026-03-09 23:26:44 +00:00
|
|
|
),
|
|
|
|
|
sm.From("publicreport.water"),
|
2026-03-18 15:36:20 +00:00
|
|
|
sm.Where(psql.Quote("report_id").EQ(
|
|
|
|
|
psql.Any(report_ids),
|
|
|
|
|
)),
|
2026-03-21 01:19:36 +00:00
|
|
|
), scan.StructMapper[types.Water]())
|
2026-03-09 23:26:44 +00:00
|
|
|
if err != nil {
|
2026-03-18 15:36:20 +00:00
|
|
|
return nil, fmt.Errorf("query water: %w", err)
|
2026-03-09 23:26:44 +00:00
|
|
|
}
|
2026-03-21 01:19:36 +00:00
|
|
|
results := make(map[int32]*types.Water, len(rows))
|
2026-03-18 15:36:20 +00:00
|
|
|
for _, row := range rows {
|
2026-03-21 01:19:36 +00:00
|
|
|
results[row.ReportID] = &types.Water{
|
2026-03-18 15:36:20 +00:00
|
|
|
AccessComments: row.AccessComments,
|
|
|
|
|
AccessGate: row.AccessGate,
|
|
|
|
|
AccessFence: row.AccessFence,
|
|
|
|
|
AccessLocked: row.AccessLocked,
|
|
|
|
|
AccessDog: row.AccessDog,
|
|
|
|
|
AccessOther: row.AccessOther,
|
|
|
|
|
Comments: row.Comments,
|
|
|
|
|
HasAdult: row.HasAdult,
|
|
|
|
|
HasBackyardPermission: row.HasBackyardPermission,
|
|
|
|
|
HasLarvae: row.HasLarvae,
|
|
|
|
|
HasPupae: row.HasPupae,
|
|
|
|
|
IsReporterConfidential: row.IsReporterConfidential,
|
|
|
|
|
IsReporterOwner: row.IsReporterOwner,
|
|
|
|
|
Owner: row.Owner,
|
|
|
|
|
ReportID: row.ReportID,
|
2026-03-14 16:13:08 +00:00
|
|
|
}
|
2026-03-09 23:26:44 +00:00
|
|
|
}
|
2026-03-18 15:36:20 +00:00
|
|
|
return results, nil
|
2026-03-12 23:49:16 +00:00
|
|
|
}
|
2026-04-12 17:53:25 +00:00
|
|
|
*/
|