Add additional source information and property areas

This commit is contained in:
Eli Ribble 2026-03-07 02:18:40 +00:00
parent 1970ccb13e
commit beb4b914a0
No known key found for this signature in database
2 changed files with 127 additions and 18 deletions

View file

@ -24,10 +24,25 @@ type reporter struct {
Name string `json:"name"`
}
type publicReport struct {
Address Address `json:"address"`
Images []string `json:"images"`
Location Location `json:"location"`
Reporter reporter `json:"reporter"`
AdditionalInfo string `json:"additional_info"`
Address Address `json:"address"`
Duration string `json:"duration"`
Images []string `json:"images"`
IsLocationBackyard bool `json:"is_location_backyard"`
IsLocationFrontyard bool `json:"is_location_frontyard"`
IsLocationGarden bool `json:"is_location_garden"`
IsLocationOther bool `json:"is_location_other"`
IsLocationPool bool `json:"is_location_pool"`
Location Location `json:"location"`
Reporter reporter `json:"reporter"`
SourceContainer bool `json:"source_container"`
SourceDescription string `json:"source_description"`
SourceGutter bool `json:"source_gutter"`
SourceStagnant bool `json:"source_stagnant"`
TODDay bool `json:"time_of_day_day"`
TODEarly bool `json:"time_of_day_early"`
TODEvening bool `json:"time_of_day_evening"`
TODNight bool `json:"time_of_day_night"`
}
type communication struct {
Created time.Time `json:"created"`
@ -41,33 +56,63 @@ type contentListCommunication struct {
func listCommunication(ctx context.Context, r *http.Request, org *models.Organization, user *models.User, query queryParams) (*contentListCommunication, *nhttp.ErrorWithStatus) {
type _Report struct {
AddressCountry string `db:"address_country" `
AddressPlace string `db:"address_place" `
AddressPostcode string `db:"address_postcode" `
AddressRegion string `db:"address_region" `
AddressStreet string `db:"address_street" `
Created time.Time `db:"created" `
Latitude float64 `db:"latitude"`
Longitude float64 `db:"longitude"`
PublicID string `db:"public_id" `
ReporterEmail *string `db:"reporter_email" `
ReporterName *string `db:"reporter_name" `
ReporterPhone *string `db:"reporter_phone" `
AdditionalInfo string `db:"additional_info"`
AddressCountry string `db:"address_country" `
AddressPlace string `db:"address_place" `
AddressPostcode string `db:"address_postcode" `
AddressRegion string `db:"address_region" `
AddressStreet string `db:"address_street" `
Created time.Time `db:"created" `
Duration string `db:"duration" `
IsLocationBackyard bool `db:"is_location_backyard"`
IsLocationFrontyard bool `db:"is_location_frontyard"`
IsLocationGarden bool `db:"is_location_garden"`
IsLocationOther bool `db:"is_location_other"`
IsLocationPool bool `db:"is_location_pool"`
Latitude float64 `db:"latitude"`
Longitude float64 `db:"longitude"`
PublicID string `db:"public_id" `
ReporterEmail *string `db:"reporter_email" `
ReporterName *string `db:"reporter_name" `
ReporterPhone *string `db:"reporter_phone" `
SourceContainer bool `db:"source_container"`
SourceDescription string `db:"source_description"`
SourceGutter bool `db:"source_gutter"`
SourceStagnant bool `db:"source_stagnant"`
TODDay bool `db:"tod_day"`
TODEarly bool `db:"tod_early"`
TODEvening bool `db:"tod_evening"`
TODNight bool `db:"tod_night"`
}
reports, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
sm.Columns(
"additional_info",
"address_country",
"address_place",
"address_postcode",
"address_region",
"address_street",
"created",
"duration",
"is_location_backyard",
"is_location_frontyard",
"is_location_garden",
"is_location_other",
"is_location_pool",
"ST_Y(location::geometry::geometry(point, 4326)) AS latitude",
"ST_X(location::geometry::geometry(point, 4326)) AS longitude",
"public_id",
"reporter_email",
"reporter_phone",
"reporter_name",
"source_container",
"source_description",
"source_gutter",
"source_stagnant",
"tod_day",
"tod_early",
"tod_evening",
"tod_night",
),
sm.From("publicreport.nuisance"),
sm.Where(psql.Quote("publicreport", "nuisance", "organization_id").EQ(psql.Arg(org.ID))),
@ -125,7 +170,14 @@ func listCommunication(ctx context.Context, r *http.Request, org *models.Organiz
Region: report.AddressRegion,
Street: report.AddressStreet,
},
Images: toImageURLs(id_to_images, report.PublicID),
AdditionalInfo: report.AdditionalInfo,
Duration: report.Duration,
Images: toImageURLs(id_to_images, report.PublicID),
IsLocationBackyard: report.IsLocationBackyard,
IsLocationFrontyard: report.IsLocationFrontyard,
IsLocationGarden: report.IsLocationGarden,
IsLocationOther: report.IsLocationOther,
IsLocationPool: report.IsLocationPool,
Location: Location{
Latitude: report.Latitude,
Longitude: report.Longitude,
@ -135,6 +187,14 @@ func listCommunication(ctx context.Context, r *http.Request, org *models.Organiz
HasEmail: report.ReporterEmail != nil,
HasPhone: report.ReporterPhone != nil,
},
SourceContainer: report.SourceContainer,
SourceDescription: report.SourceDescription,
SourceGutter: report.SourceGutter,
SourceStagnant: report.SourceStagnant,
TODDay: report.TODDay,
TODEarly: report.TODEarly,
TODEvening: report.TODEvening,
TODNight: report.TODNight,
},
Type: "nuisance",
}

View file

@ -508,6 +508,28 @@
<label class="form-label text-muted small mb-0">
<i class="bi bi-clock"></i> Time of Day Encountered
</label>
<ul>
<template
x-if="selectedCommunication.public_report.time_of_day_early"
>
<li>Early</li>
</template>
<template
x-if="selectedCommunication.public_report.time_of_day_day"
>
<li>Daytime</li>
</template>
<template
x-if="selectedCommunication.public_report.time_of_day_evening"
>
<li>Evening</li>
</template>
<template
x-if="selectedCommunication.public_report.time_of_day_night"
>
<li>Night</li>
</template>
</ul>
<div
class="fw-medium"
x-text="selectedCommunication.timeOfDay"
@ -518,6 +540,33 @@
<i class="bi bi-house"></i> Property Area
</label>
<div>
<ul>
<template
x-if="selectedCommunication.public_report.is_location_backyard"
>
<li>Backyard</li>
</template>
<template
x-if="selectedCommunication.public_report.is_location_frontyard"
>
<li>Frontyard</li>
</template>
<template
x-if="selectedCommunication.public_report.is_location_garden"
>
<li>Garden</li>
</template>
<template
x-if="selectedCommunication.public_report.is_location_other"
>
<li>Other</li>
</template>
<template
x-if="selectedCommunication.public_report.is_location_pool"
>
<li>Pool</li>
</template>
</ul>
<template
x-for="area in selectedCommunication.propertyAreas"
:key="area"
@ -535,7 +584,7 @@
</label>
<div
class="p-2 bg-light rounded"
x-text="selectedCommunication.notes || 'No additional notes'"
x-text="selectedCommunication.public_report.additional_info || 'No additional notes'"
></div>
</div>
</div>