Pass-through an address shim with whatever data we have
This commit is contained in:
parent
d1ba2f53fa
commit
28cf7683a7
1 changed files with 24 additions and 18 deletions
|
|
@ -8,10 +8,10 @@ import (
|
||||||
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
||||||
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||||
querypublic "github.com/Gleipnir-Technology/nidus-sync/db/query/public"
|
|
||||||
querypublicreport "github.com/Gleipnir-Technology/nidus-sync/db/query/publicreport"
|
|
||||||
modelpublic "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model"
|
modelpublic "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/public/model"
|
||||||
modelpublicreport "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model"
|
modelpublicreport "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model"
|
||||||
|
querypublic "github.com/Gleipnir-Technology/nidus-sync/db/query/public"
|
||||||
|
querypublicreport "github.com/Gleipnir-Technology/nidus-sync/db/query/publicreport"
|
||||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||||
//"github.com/google/uuid"
|
//"github.com/google/uuid"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
@ -80,6 +80,8 @@ func reportQueryToRows(ctx context.Context, reports []modelpublicreport.Report,
|
||||||
report_ids[i] = report.ID
|
report_ids[i] = report.ID
|
||||||
if report.AddressID != nil {
|
if report.AddressID != nil {
|
||||||
address_ids = append(address_ids, int64(*report.AddressID))
|
address_ids = append(address_ids, int64(*report.AddressID))
|
||||||
|
} else {
|
||||||
|
log.Debug().Int32("id", report.ID).Msg("has no address")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
images_by_id, err := loadImagesForReport(ctx, report_ids)
|
images_by_id, err := loadImagesForReport(ctx, report_ids)
|
||||||
|
|
@ -124,30 +126,34 @@ func reportQueryToRows(ctx context.Context, reports []modelpublicreport.Report,
|
||||||
address = &a
|
address = &a
|
||||||
}
|
}
|
||||||
if address == nil {
|
if address == nil {
|
||||||
return nil, fmt.Errorf("nil address: %w", err)
|
address = &types.Address{
|
||||||
|
ID: row.AddressID,
|
||||||
|
GID: row.AddressGid,
|
||||||
|
Raw: row.AddressRaw,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
results[i] = types.PublicReport{
|
results[i] = types.PublicReport{
|
||||||
Address: *address,
|
Address: *address,
|
||||||
Concerns: nil,
|
Concerns: nil,
|
||||||
Created: row.Created,
|
Created: row.Created,
|
||||||
ID: row.ID,
|
ID: row.ID,
|
||||||
Images: images,
|
Images: images,
|
||||||
Location: location,
|
Location: location,
|
||||||
Log: logs,
|
Log: logs,
|
||||||
DistrictID: &row.OrganizationID,
|
DistrictID: &row.OrganizationID,
|
||||||
District: nil,
|
District: nil,
|
||||||
PublicID: row.PublicID,
|
PublicID: row.PublicID,
|
||||||
Reporter: types.Contact{
|
Reporter: types.Contact{
|
||||||
CanSMS: &row.ReporterPhoneCanSms,
|
CanSMS: &row.ReporterPhoneCanSms,
|
||||||
Email: &row.ReporterEmail,
|
Email: &row.ReporterEmail,
|
||||||
HasEmail: row.ReporterEmail != "",
|
HasEmail: row.ReporterEmail != "",
|
||||||
HasPhone: row.ReporterPhone != "",
|
HasPhone: row.ReporterPhone != "",
|
||||||
Name: &row.ReporterName,
|
Name: &row.ReporterName,
|
||||||
Phone: &row.ReporterPhone,
|
Phone: &row.ReporterPhone,
|
||||||
},
|
},
|
||||||
Status: row.Status.String(),
|
Status: row.Status.String(),
|
||||||
Type: row.ReportType.String(),
|
Type: row.ReportType.String(),
|
||||||
URI: "",
|
URI: "",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results, nil
|
return results, nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue