pinballmap / pbm

Pinball Map
https://pinballmap.com
GNU General Public License v3.0
110 stars 25 forks source link

Use the active flag on locations #1507

Closed RyanTG closed 1 year ago

RyanTG commented 1 year ago

I don’t think I understand all the moving parts of this yet, but I will try to work it out.

Motives:

1) when we use the list_within_range user submission endpoint, it only returns user submissions for existing locations. Sometimes machines are removed and then the location deleted, but those machine removal submissions are not returned after the location is deleted and so the activity is lost from the record.

2) locations are sometimes removed but then re-added. When they are, the new location has a new ID and brand new history.

Both points could be resolved if we did not delete locations but instead made them inactive.

We have an “active” flag on locations that we do not use.

Weekly auto-delete script could instead make locations inactive.

Website only displays active locations.

When location is added or submitted location is approved, active flag is automatically set.

Might be easier to instead use an “inactive” flag, and just have it set to null by default.

list_within_range endpoint includes inactive.

more later…

RyanTG commented 1 year ago

Noting that a possible simple solution to the issue of list_within_range endpoint not including deleted locations might be to include lat lon fields in the user_submissions table and query that table in the endpoint instead of locations.

RyanTG commented 1 year ago

Closing as resolved.

This only solves the list_within_range issue (of user submissions from deleted locations being removed). The solution is the one noted in the comment above.

Setup: https://github.com/pinballmap/pbm/commit/7c6edee77205015d7f9711ffbf42610b821fad97 Execution: https://github.com/pinballmap/pbm/commit/964dda68d4a1671cedfbfe77446fdf0f2c4ef119

Also, made a mistake the first time and didn't exclude "order" in the near geocoder query (seen in this commit that was reverted. Without that, it only sorts by distance.