Remove now-empty report address fields
We'll instead create address rows and reference those
This commit is contained in:
parent
5306f8ba62
commit
9ba99d5ceb
10 changed files with 128 additions and 312 deletions
|
|
@ -81,15 +81,9 @@ func (res *nuisanceR) Create(ctx context.Context, r *http.Request, n nuisanceFor
|
|||
log.Info().Str("address.raw", address.Raw).Str("address.gid", address.GID).Msg("making nuisance")
|
||||
setter_report := models.PublicreportReportSetter{
|
||||
//AddressID: omitnull.From(latlng.Cell.String()),
|
||||
AddressCountry: omit.From(""),
|
||||
AddressGid: omit.From(address.GID),
|
||||
AddressNumber: omit.From(""),
|
||||
AddressLocality: omit.From(""),
|
||||
AddressPostalCode: omit.From(""),
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
AddressRegion: omit.From(""),
|
||||
AddressStreet: omit.From(""),
|
||||
Created: omit.From(time.Now()),
|
||||
AddressGid: omit.From(address.GID),
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
Created: omit.From(time.Now()),
|
||||
//H3cell: omitnull.From(latlng.Cell.String()),
|
||||
LatlngAccuracyType: omit.From(enums.PublicreportAccuracytypeBrowser),
|
||||
LatlngAccuracyValue: omit.From(accuracy),
|
||||
|
|
|
|||
|
|
@ -40,20 +40,6 @@ func (res *publicreportR) ByID(ctx context.Context, r *http.Request, query Query
|
|||
populateReportURI(report, res.router)
|
||||
return report, nil
|
||||
}
|
||||
func (res *publicreportR) ByIDCompliance(ctx context.Context, r *http.Request, query QueryParams) (*types.PublicReportCompliance, *nhttp.ErrorWithStatus) {
|
||||
vars := mux.Vars(r)
|
||||
public_id := vars["id"]
|
||||
if public_id == "" {
|
||||
return nil, nhttp.NewBadRequest("You must provid an ID")
|
||||
}
|
||||
report, err := platform.PublicreportByIDCompliance(ctx, public_id)
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("get report: %w", err)
|
||||
}
|
||||
populateDistrictURI(&report.PublicReport, res.router)
|
||||
populateReportURI(&report.PublicReport, res.router)
|
||||
return report, nil
|
||||
}
|
||||
func (res *publicreportR) ByIDNuisance(ctx context.Context, r *http.Request, query QueryParams) (*types.PublicReportNuisance, *nhttp.ErrorWithStatus) {
|
||||
vars := mux.Vars(r)
|
||||
public_id := vars["id"]
|
||||
|
|
@ -104,21 +90,17 @@ func (res *publicreportR) ImageCreate(ctx context.Context, r *http.Request, n nu
|
|||
return &image{Status: "ok"}, nil
|
||||
}
|
||||
|
||||
type complianceForm struct {
|
||||
Comments *string `schema:"comments"`
|
||||
}
|
||||
|
||||
type publicreportForm struct {
|
||||
type publicreportComplianceForm struct {
|
||||
Address *types.Address `schema:"address"`
|
||||
ClientID string `schema:"client_id"`
|
||||
Compliance *complianceForm `schema:"compliance"`
|
||||
Comments *string `schema:"comments"`
|
||||
DistrictID string `schema:"district"`
|
||||
Location *types.Location `schema:"location"`
|
||||
Locator *Locator `schema:"locator"`
|
||||
Reporter *types.Contact `schema:"reporter"`
|
||||
}
|
||||
|
||||
func (res *publicreportR) Update(ctx context.Context, r *http.Request, prf publicreportForm) (*types.PublicReport, *nhttp.ErrorWithStatus) {
|
||||
func (res *publicreportR) UpdateCompliance(ctx context.Context, r *http.Request, prf publicreportComplianceForm) (*types.PublicReport, *nhttp.ErrorWithStatus) {
|
||||
vars := mux.Vars(r)
|
||||
public_id := vars["id"]
|
||||
if public_id == "" {
|
||||
|
|
@ -143,7 +125,7 @@ func (res *publicreportR) Update(ctx context.Context, r *http.Request, prf publi
|
|||
report_setter.ReporterPhone = omit.From(*prf.Reporter.Phone)
|
||||
}
|
||||
}
|
||||
report, err := platform.PublicReportUpdate(ctx, public_id, report_setter, prf.Address, prf.Location)
|
||||
report, err := platform.PublicReportUpdateCompliance(ctx, public_id, report_setter, prf.Address, prf.Location)
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("update report: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import (
|
|||
//"github.com/Gleipnir-Technology/nidus-sync/html"
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
"github.com/gorilla/mux"
|
||||
//"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
|
|
@ -30,18 +32,26 @@ type compliance struct {
|
|||
URI string `json:"uri"`
|
||||
}
|
||||
|
||||
func (res *complianceR) Create(ctx context.Context, r *http.Request, n publicreportForm) (*compliance, *nhttp.ErrorWithStatus) {
|
||||
func (res *complianceR) ByID(ctx context.Context, r *http.Request, query QueryParams) (*types.PublicReportCompliance, *nhttp.ErrorWithStatus) {
|
||||
vars := mux.Vars(r)
|
||||
public_id := vars["id"]
|
||||
if public_id == "" {
|
||||
return nil, nhttp.NewBadRequest("You must provid an ID")
|
||||
}
|
||||
report, err := platform.PublicreportByIDCompliance(ctx, public_id)
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("get report: %w", err)
|
||||
}
|
||||
populateDistrictURI(&report.PublicReport, res.router)
|
||||
populateReportURI(&report.PublicReport, res.router)
|
||||
return report, nil
|
||||
}
|
||||
func (res *complianceR) Create(ctx context.Context, r *http.Request, n publicreportComplianceForm) (*compliance, *nhttp.ErrorWithStatus) {
|
||||
setter_report := models.PublicreportReportSetter{
|
||||
//AddressID: omitnull.From(latlng.Cell.String()),
|
||||
AddressCountry: omit.From(""),
|
||||
AddressGid: omit.From(""),
|
||||
AddressNumber: omit.From(""),
|
||||
AddressLocality: omit.From(""),
|
||||
AddressPostalCode: omit.From(""),
|
||||
AddressRaw: omit.From(""),
|
||||
AddressRegion: omit.From(""),
|
||||
AddressStreet: omit.From(""),
|
||||
Created: omit.From(time.Now()),
|
||||
AddressGid: omit.From(""),
|
||||
AddressRaw: omit.From(""),
|
||||
Created: omit.From(time.Now()),
|
||||
//H3cell: omitnull.From(latlng.Cell.String()),
|
||||
LatlngAccuracyType: omit.From(enums.PublicreportAccuracytypeBrowser),
|
||||
LatlngAccuracyValue: omit.From(float32(0.0)),
|
||||
|
|
@ -70,14 +70,9 @@ func (res *waterR) Create(ctx context.Context, r *http.Request, w waterForm) (*w
|
|||
accuracy = *w.Location.Accuracy
|
||||
}
|
||||
setter_report := models.PublicreportReportSetter{
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
AddressCountry: omit.From(""),
|
||||
AddressNumber: omit.From(""),
|
||||
AddressLocality: omit.From(""),
|
||||
AddressPostalCode: omit.From(""),
|
||||
AddressRegion: omit.From(""),
|
||||
AddressStreet: omit.From(""),
|
||||
Created: omit.From(time.Now()),
|
||||
AddressGid: omit.From(address.GID),
|
||||
AddressRaw: omit.From(address.Raw),
|
||||
Created: omit.From(time.Now()),
|
||||
//H3cell: omitnull.From(geospatial.Cell.String()),
|
||||
LatlngAccuracyType: omit.From(enums.PublicreportAccuracytypeBrowser),
|
||||
LatlngAccuracyValue: omit.From(accuracy),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue