This is an in-progress, proof-of-concept, not-ready-for-primetime, etc, PR to help with discussion. Hopefully it'll progress to a mergeable state, but for now let's gather some feedback.
--- Fixes https://github.com/openstreetmap/openstreetmap-website/issues/6570 (Enable PostGIS). This PR introduces "geoblock zones" where anonymous notes are not allowed. It also enables PostGIS in the process. This addresses https://github.com/openstreetmap/openstreetmap-website/issues/6567 partially: - Within the geoblock zones, only anonymous accounts are blocked, not "recent" ones. We can measure the success of this one before moving on to recent accounts which are a bit more complex. - No UI for moderators to define the zones. For now let's manually put some zones in DB and see how it goes. If we see success, we can add the UI. Misc notes: - I'm sure I'm doing geometry/geography wrong somewhere. Please let me know. - Using the gem `activerecord-postgis-adapter`. - Technically I don't think I really need it, but if I don't use it I get a warning `unknown OID 80148: failed to recognize type of 'zone'. It will be treated as String.`, which I guess is fair enough. - A different gem exists, https://github.com/seuros/activerecord-postgis, which appears to provide the same functionality and doesn't require setting `adapter: postgis` in `database.yml`. Any preferences? - The check is done with a verbatim `WHERE` clause instead of a fancy Arel thing because `ST_Cover` doesn't appear to be implemented by the gem (also not in the other gem). - Sorry about the unsafe interpolation. It's a workaround as the proper `?`, etc was giving me a `ActiveRecord::StatementInvalid: PG::IndeterminateDatatype: ERROR: could not determine data type of parameter $1`. Didn't want to spend time on this just now. - I wanted to use `ST_Cover` instead of `ST_Contains` (which is supported) because it appears to be more appropriate for geography vs geometry, but I might be wrong. - GitHub actions will also require enabling PostGIS, with something like https://github.com/marketplace/actions/setup-postgresql-and-postgis-for-linux-macos-windows - If an anonymous user writes a long, toughtful note, submits it, but then it fails because it was a geoblocked area... Is that OK? - Currently there's no way for clients to know that they can't comment on a specific location, ahead of time. - We could introduce an API to allow checking for this. Something like `GET /api/0.6/notes/allowed?lat=X&lon=Y`. You can view, comment on, or merge this pull request online at: https://github.com/openstreetmap/openstreetmap-website/pull/6713 -- Commit Summary -- * Enable PostGIS * Add PostGIS adapter * Add table to store geoblock zones * Proof of concept -- File Changes -- M Gemfile (3) M Gemfile.lock (8) M app/controllers/api/notes_controller.rb (2) A app/models/geoblock_zone.rb (30) M config/docker.database.yml (2) M config/example.database.yml (2) M config/github.database.yml (2) A db/migrate/20260113142804_enable_postgis.rb (7) A db/migrate/20260113144310_create_geoblock_zones.rb (12) M db/structure.sql (63) M test/controllers/api/notes_controller_test.rb (45) A test/models/geoblock_zone_test.rb (33) -- Patch Links -- https://github.com/openstreetmap/openstreetmap-website/pull/6713.patch https://github.com/openstreetmap/openstreetmap-website/pull/6713.diff -- Reply to this email directly or view it on GitHub: https://github.com/openstreetmap/openstreetmap-website/pull/6713 You are receiving this because you are subscribed to this thread. Message ID: <openstreetmap/openstreetmap-website/pull/[email protected]>
_______________________________________________ rails-dev mailing list [email protected] https://lists.openstreetmap.org/listinfo/rails-dev
