Mosquito check: admin-editable send message, off-property save fix, closer geocode, solution copy updates #211
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "mosquito-check-updates"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mosquito check: admin-editable send message, off-property save fix, closer geocode, solution copy updates
5 commits from the light-rat branch, split out for review. Rebased onto current main (
fe6c6bd0). Builds on the short-link/campaign work already on main or landing in the short-links-click-tracking PR — none of these commits depend on that PR's code, but the send-message flow delivers the short link minted by CommunicationMosquitoCheckCreate.1. Admin-editable message for Mosquito Check sends
Previously the SMS/email sent to a resident when staff send a Mosquito Check used one hard-coded bilingual line. Now the send accepts an optional custom message.
2. Fix off-property save missing unique constraint
Migration 00363. OffPropertyUpsert relies on ON CONFLICT (virtual_inspection_id, category), but migration 00321 omitted the unique constraint, so every off-property save failed with SQLSTATE 42P10. Adds the unique constraint; one block per category per inspection is the domain rule.
3. Reverse-closest geocode ignores far-away admin features
platform/geocode/geocode.go: ReverseGeocodeClosest previously considered administrative polygon layers (county, region, country, empire, continent, ocean, ...) whose stored point is a representative centroid that can be hundreds of km from the query point — a "preferred" admin layer could win over a genuinely nearby address/street result or over nothing. Now:
4. Tarp and yard drain solution copy
db/migrations/00321_virtual_inspection.sql: updates the EN/ES solution copy for the Tarp or plastic cover and Yard drain habitat types (e.g. yard drain now suggests fitting screen mesh over the pipe opening and notes residents may request mesh from the district). doc/mosquito-check-solutions.md updated to match.
Caveat: 00321 already exists on main; if it has already run in an environment, the edited INSERT rows will not re-apply there — only fresh databases see the new copy. Confirm this is acceptable before merge, or move the copy change into a new migration.
Files
11 changed: 2 migrations (00321 modified, 00359 added), platform/geocode/geocode.go, platform/virtual_inspection.go, resource/communication.go, platform/email/virtual_inspection_request.go + 2 email templates, MosquitoCheckSendModal.vue (new), Communication.vue, doc/mosquito-check-solutions.md.
Verification
Update (2026-09-04)
Rebased onto current main (
493c13f8). Migration renumbered again: 00359 → 00363 (main consumed 00358-00361 today). Verified: gofmt, go build -tags tiff, TestMosquitoCheckRoutesRegister, build-sync, build-rmo all pass on the rebuilt branch.4102a26c08740e61d103@ -105,3 +105,2 @@'Una lona sobre leña, equipo o un vehículo donde el agua se acumula en los pliegues.','Pull tarps tight so water can''t pool.<br>Poke small drainage holes at the low points.<br>Store items under a solid roof when possible.','Estire las lonas para que el agua no se acumule.<br>Haga pequeños agujeros de drenaje en los puntos bajos.<br>Guarde los objetos bajo un techo sólido cuando sea posible.','Pull tarps tight so they have no dips or hollows where water can pool.<br>If water does collect, empty it out.<br>Check that sprinklers are not refilling the tarp.',This likely won't work the way you're hoping. We've already run this migration in every environment and changing it now won't do anything to the displayed text. You'll need to either create a new migration to change this content in the database or port the content out of the database (which is what I'd recommend).
@ -862,0 +864,4 @@// the literal {link} placeholder is substituted with the short link at send// time. The frontend send modal prefills this same string, so it must match// exactly.const defaultMosquitoCheckMessage = "Delta MVCD Mosquito Check — complete your guided yard check: {link}"Definitely should not have 'Delta MVCD', a specific customer, in the code base as a default. Feel free to inject the current active customer, similar to how the link is injected, but not this.
@ -0,0 +82,4 @@// (platform/virtual_inspection.go CommunicationMosquitoCheckCreate). The// literal {link} placeholder is substituted with the short link at send time.const DEFAULT_MESSAGE ="Delta MVCD Mosquito Check — complete your guided yard check: {link}";Same as above, should not have a checked-in customer specific message in code.
740e61d103142aa1e912All three review comments addressed. Branch also rebased onto current main, and the off-property migration was renumbered 00363 → 00365 (main now owns 00363_short_link / 00364_job_history — a duplicate 00363 would have broken the migration sequence at startup).
ts/rmo/content/mosquito/habitatCopy.ts, zero-import, shared by the resident walk and the sync staff card); the API no longer serves habitat text (0bb05b8f); migration 00366 drops the six text columns (1c73b0aa); the 00321 wording edit is reverted.7482f3b0); email subject and footer are org-driven with a dynamic year; the modal opens blank with a "leave blank for the district's default message" hint (b18bff9c), so the send copy has one server-side source.org_name/phone_office; the wizard's remaining district/phone references are tokenized ({district_name}/{district_phone}) and substituted at render from org state (ad5a10a2,886f8c8e,842294ce).doc/mosquito-check-solutions.mdstays canonical and notes the token behavior.Verified on the final head:
go build -tags tiff,pnpm build-rmo,pnpm build-syncall pass; pre-commit hooks clean per commit.Two notes: the invalid/expired-link screen has no org context (no inspection exists), so it renders a neutral "contact your mosquito control district" line without a phone — happy to wire the district phone in another way if that screen needs it. And snail-mailer templates remain per-district authored content (out of scope for org-parameterization by design).
Reply to your review comment on
db/migrations/00321_virtual_inspection.sql:Fixed: habitat wording no longer lives in the database at all, so there is no seeded copy to go stale.
ts/rmo/content/mosquito/habitatCopy.ts, a zero-import module shared by the resident walk and the sync staff card (158b927a).habitat_type(0bb05b8f); the sync staff card resolves labels from the same dictionary by key.1c73b0aa).doc/mosquito-check-solutions.mdremains the canonical human copy reference.Later commits tokenize the district references those rows carried (
{district_name}/{district_phone}) — see the summary comment.Reply to your review comment on
platform/virtual_inspection.go(default send message):Fixed: the hard-coded default is gone. With an empty message the send now composes
<OrgName> Mosquito Check — complete your guided yard check: <link>at send time fromuser.Organization.Name()(7482f3b0), i.e. the active customer is injected exactly like the link. The email subject (Your Mosquito Check — <OrgName>) and template footer (dynamic year + org name) are org-driven too, and the doc comments now describe the two channel defaults accurately (SMS one-liner vs canned bilingual email). No customer literal remains inplatform/virtual_inspection.go.Reply to your review comment on
ts/components/MosquitoCheckSendModal.vue:Fixed in
b18bff9c: the modal no longer carries aDEFAULT_MESSAGEliteral (or the "must match exactly" comment). It opens blank with helper text —{link}is replaced automatically; leave blank to send the district's default message — and the server owns the default composition, so the send copy has a single source. Staff can still type a custom message per resident.