Add 'submitted' field to compliance reports

This commit is contained in:
Eli Ribble 2026-04-27 16:23:16 +00:00
parent 8a05ba2faf
commit be8d92d7ae
No known key found for this signature in database
6 changed files with 87 additions and 14 deletions

View file

@ -81,6 +81,21 @@ func PublicreportByIDNuisance(ctx context.Context, report_id string) (*types.Pub
func PublicreportByIDWater(ctx context.Context, report_id string) (*types.PublicReportWater, error) {
return publicreport.ByIDWater(ctx, report_id)
}
func PublicreportComplianceSubmit(ctx context.Context, report_id string) (*types.PublicReportCompliance, error) {
report, err := publicreport.ByIDCompliance(ctx, report_id)
if err != nil {
return nil, fmt.Errorf("byidcompliance: %w", err)
}
_, err = psql.Update(
um.Table(models.PublicreportCompliances.NameAs()),
um.SetCol(models.PublicreportCompliances.Columns.Submitted.String()).ToArg(time.Now()),
um.Where(models.PublicreportCompliances.Columns.ReportID.EQ(psql.Arg(report.ReportID))),
).Exec(ctx, db.PGInstance.BobDB)
if err != nil {
return nil, fmt.Errorf("update report submitted: %w", err)
}
return publicreport.ByIDCompliance(ctx, report_id)
}
func PublicreportInvalid(ctx context.Context, user User, public_id string) error {
report, err := publicReportFromID(ctx, public_id)
if err != nil {

View file

@ -23,15 +23,16 @@ type PublicReport struct {
type PublicReportCompliance struct {
PublicReport
AccessInstructions string `db:"access_instructions" json:"access_instructions"`
AvailabilityNotes string `db:"availability_notes" json:"availability_notes"`
Comments string `db:"comments" json:"comments"`
GateCode string `db:"gate_code" json:"gate_code"`
HasDog *bool `db:"has_dog" json:"has_dog"`
PermissionType string `db:"permission_type" json:"permission_type"`
ReportID int32 `db:"report_id" json:"-"`
ReportPhoneCanText *bool `db:"report_phone_can_text" json:"can_text"`
WantsScheduled *bool `db:"wants_scheduled" json:"wants_scheduled"`
AccessInstructions string `db:"access_instructions" json:"access_instructions"`
AvailabilityNotes string `db:"availability_notes" json:"availability_notes"`
Comments string `db:"comments" json:"comments"`
GateCode string `db:"gate_code" json:"gate_code"`
HasDog *bool `db:"has_dog" json:"has_dog"`
PermissionType string `db:"permission_type" json:"permission_type"`
ReportID int32 `db:"report_id" json:"-"`
ReportPhoneCanText *bool `db:"report_phone_can_text" json:"can_text"`
Submitted *time.Time `db:"submitted" json:"submitted"`
WantsScheduled *bool `db:"wants_scheduled" json:"wants_scheduled"`
}
type PublicReportNuisance struct {
PublicReport