[openstreetmap/openstreetmap-website] Add deactivates_at date to user blocks (PR #5069)

Anton Khorev notifications at github.com
Tue Aug 13 11:21:38 UTC 2024


Block deactivation dates that take needs_view-block views into account were derived using updated_at. This was possible because inactive blocks couldn't be edited and their updated_at date wouldn't change. The logic is explained here:

https://github.com/openstreetmap/openstreetmap-website/blob/e0e6c7f1c26fcddff883dad38a6207475150f323/app/helpers/user_blocks_helper.rb#L20-L24

With editing of inactive blocks enabled deactivation date needs to be saved explicitly. It is defined for blocks that don't have `needs_view` and will time out even if the user doesn't look at them. Block with `needs_view` don't have a defined deactivation date. It's going to be set as soon as the user views the block and clears `needs_view`. Its value is going to be either the block end date if it's in the future or the current date.

---

After creating `deactivates_at` we no longer need `needs_view`. A block with `needs_view` is just a block without `deactivates_at`. But I can't remove `needs_view` right away because strong_migrations won't let me to drop the column without extra steps.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/5069

-- Commit Summary --

  * Add deactivates_at date to user blocks

-- File Changes --

    M app/controllers/user_blocks_controller.rb (27)
    M app/helpers/user_blocks_helper.rb (2)
    M app/models/user_block.rb (24)
    A db/migrate/20240813070506_add_deactivates_at_to_user_blocks.rb (5)
    M db/structure.sql (4)
    M test/controllers/user_blocks_controller_test.rb (128)
    M test/factories/user_blocks.rb (2)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/5069.patch
https://github.com/openstreetmap/openstreetmap-website/pull/5069.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5069
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5069 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240813/831ad8fc/attachment.htm>


More information about the rails-dev mailing list